gdi+

Fonts added with AddFontResourceEx are not working in GDI+

谁都会走 提交于 2019-12-25 18:42:22
问题 AddFontResourceEx returns 1 for each font, but the fonts are not accesible in GDI+ (Tested with VS2015 and Windows 10, also on Windows 2008 R2 Server). If I install the fonts manually with Windows Fonts Explorer everything works ok. It seems that GDI+ cannot find the fonts added with AddFontResourceEx or AddFontResource, any idea how can I get this working? I use CodeJock Library which uses GDI+ fonts for rendering XAML graphics, so I cannot control how to fonts are created. int n = 0; CPathW

Graphics.DrawImage Doesn't Always Paint The Whole Bitmap?

Deadly 提交于 2019-12-25 14:05:14
问题 I have run into a strange problem when using Graphics.DrawImage . When using e.Graphics.DrawImage(Image, Point) in OnPaint to paint a bitmap 'buffer' on the control, it appears that parts of the image are omitted. The buffer is populated in a helper method which draws directly onto the Bitmap using a Graphics constructed from it. When the control paints, the cached bitmap is drawn on the control. Nothing appears to be omitted on the bitmap itself, because when I saved the bitmap to disc and

How to paint additional things on a drawn panel?

南楼画角 提交于 2019-12-25 09:29:10
问题 I'm reading a lot about C# drawing and reading MSDN tutorial on GDI+ using Graphics handlers. I want to be able to paint a graph, which nodes I have in a list but I can't use auto-placing, I need the nodes to be in a specified place and have specific appearance and so on, changing over time, that's why I stopped looking for graph libraries. It all works great when painted for the first time but when I want something painted after something else happens in the code (not after clicking the

overlaying images with GDI+

时光总嘲笑我的痴心妄想 提交于 2019-12-25 03:46:32
问题 I'm trying to overlay a image with a couple of other images. I use this code to do that: Dim gbkn As Bitmap = New Bitmap(7001, 7001, Imaging.PixelFormat.Format32bppArgb) Dim g As Graphics = Graphics.FromImage(CType(gbkn, Image)) g.DrawImage(Image.FromFile("C:\background.png"), New Point(0, 0)) g.DrawImage(Image.FromFile("C:\firstlayer.png"), New Point(0, 0)) g.DrawImage(Image.FromFile("C:\secondlayer.png"), New Point(0, 0)) This works with the first two pictures. After that an

Creating a image viewer window controll

主宰稳场 提交于 2019-12-25 03:38:34
问题 I am learning GDI+ and I am trying to make a display window with scroll bars (so I can only see part of the image at a time and I can scroll around it). I have read through the basics of GDI+ from several books but I have not found any good tutorials online or in books available to me about doing more advanced things like this. Any recommendations on guides or example code on how do do this? Here is what I have so far protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); if

BitmapPalette Insufficient memory exception

谁说胖子不能爱 提交于 2019-12-24 18:05:11
问题 I have the following piece of code that runs in a loop. public void Test(Bitmap bmp) { FormatConvertedBitmap fBitmapSource = new FormatConvertedBitmap(); PngBitmapEncoder pngBitmapEncoder = new PngBitmapEncoder(); BitmapImage bi = new BitmapImage(); using (MemoryStream ms = new MemoryStream()) { bmp.Save(ms, ImageFormat.Png); bmp.Dispose(); bmp = null; bi.BeginInit(); bi.StreamSource = ms; bi.EndInit(); BitmapPalette pallete = new BitmapPalette(bi, 256); ... Last line BitmapPalette pallete =

Select Area of Image

余生长醉 提交于 2019-12-24 17:43:30
问题 I'm trying to select an area of an image I've selected using openfiledialog The area I'm trying to select is 16x16 from x,y coordinates 5,5 Once selected I want to draw the 16x16 image into another pictureBox at coordinates 0,0 This is the code I've got but I can't get it to select the correct part of the original image, anybody any suggestions as to why it doesn't work? DialogResult result = openFileDialog1.ShowDialog(); if (result == DialogResult.OK) // Test result. { Image origImage =

How to control the orientation of Drawstring?

隐身守侯 提交于 2019-12-24 16:54:30
问题 I want to draw a string as an axis label. When I draw the string with following code, I can read it "from the left". The base line of the text is at the left side. StringFormat format = CustomGraphics.StringFormat(ContentAlignment.MiddleCenter); format.FormatFlags |= StringFormatFlags.DirectionVertical; e.Graphics.DrawString(this.yAxis.Title.Text, this.yAxis.Title.Font, textBrush, e.Bounds, format); format.FormatFlags &= ~StringFormatFlags.DirectionVertical; I want to draw vertical but turn

Custom font styles with graphics

旧巷老猫 提交于 2019-12-24 15:33:45
问题 I have the following list of fonts: I have no issues with using them via new Font("XXXX Sans", 21, FontStyle.Bold, GraphicsUnit.Pixel) However, what do i do when i need to use a non-standard font style like light? All that is provided is an enumeration and that is not suitable. 回答1: Can you not just use the font name as it appears in the control panel? Most fonts that aren't regular, bold or italic actually have a subfamily type of "regular" anyways. If you download the font properties

How to get a 32bpp bitmap/image from a GDI Device Context?

夙愿已清 提交于 2019-12-24 12:33:01
问题 I am using code from this Project http://www.codeproject.com/Articles/9064/Yet-Another-Transparent-Static-Control in order to draw transparent button images from my subclassed Button control onto my CDialogEx. This code is meant for legacy 24bpp GDI functions: BOOL CTransparentStatic2::OnEraseBkgnd(CDC* pDC) { if (m_Bmp.GetSafeHandle() == NULL) { CRect Rect; GetWindowRect(&Rect); CWnd *pParent = GetParent(); ASSERT(pParent); pParent->ScreenToClient(&Rect); //convert our corrdinates to our