gdi+

Converting 24BPP to 4BPP with GDI+ in VB.NET

纵饮孤独 提交于 2019-12-06 14:02:22
My VB.NET program currently takes a 4BPP TIFF as an Bitmap, converts it to a Graphic, adds some text strings and then saves it out again as a TIFF file. The output Bitmap.Save() TIFF file by default seems to be 24BPP (regardless of the input) and is a lot larger than the original TIFF. Is it possible to keep the same 4BPP palette encoding as the input for the output and if not, how can I convert my Bitmap PixelFormat from 24BPP to 4BPP Indexed. I've seen an example for converting 24 BPP to 1 BPP at http://www.bobpowell.net/onebit.htm using BitmapData.Lockbits() but cannot figure out how to do

Generic GDI+ exception in GraphicsPath.AddString() with certain fonts and characters

两盒软妹~` 提交于 2019-12-06 13:59:48
Any ideas why one of recent Windows updates causes issues with GraphicsPath.AddString() and some fonts but only for specific characters? How to fix that? Example font is Thin Pencil Handwriting (it's public domain, so you can try for yourself). It works fine if you use Graphics.DrawString() with it. It also works fine if you try to use GraphicsPath.AddString() with it to write Lorem ipsum , but will fail if you try to use C character (capital c ) or 5 digit. It worked perfectly fine just few weeks ago and after recent updates it fails miserably with the infamous and virtually undebuggable

GDI+ DrawImage of a JPG with white background is not white

一世执手 提交于 2019-12-06 13:31:13
I am displaying a JPG in a C++ CWnd window using GDI+. The JPG has a pure white background, 0xffffff, but when displayed using graphics.DrawImage, the background is off-white with a mix of pixel colors such as 0xfff7f7, 0xf7fff7, 0xf7f7f7. Below is the code, I have tried various settings such as CompositingMode, SmoothingMode, etc. The image is not scaled. The weird thing is that the background color is different depending on other non-white content in the image. If I make a simple all white JPG, then it works, or even a mostly white with just some black text. Comparison of images are shown

gdipluspath throws ambiguous byte for cstddef and rpcndr.h

我的梦境 提交于 2019-12-06 08:16:21
I am currently updating an ancient program which was last compiled with visual studio 2008. I am updating it (.lib project) to visual studio 2017 for the newest windows sdk (10.0.15063.0), however, the gdiplus library throws an ambiguous symbol error. More specifically: 3>c:\program files (x86)\windows kits\10\include\10.0.15063.0\um\GdiplusPath.h(145): error C2872: 'byte': ambiguous symbol 3>c:\program files (x86)\windows kits\10\include\10.0.15063.0\shared\rpcndr.h(191): note: could be 'unsigned char byte' 3>C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.11

Rotating part of an image in 3D space

▼魔方 西西 提交于 2019-12-06 06:59:48
Here's the setup: This is for an ecommerce art site where some paintings are canvas transfers. The painting wraps around the sides and top and bottom of the canvas. We have high-res images of the entire painting, but what we want to display is a quasi-3D representation of the image in which you can see how the sides of the painting wrap around the canvas. Here's a rough sketch of what I'm talking about: My question is, how can I rotate an image in 3D space? The approach I think I'd like to take, is to cut off a portion of the top and side of the image, and rotate then in 3D and then stich it

Delphi/GDI+: When is a Device Context created/destroyed?

隐身守侯 提交于 2019-12-06 06:29:01
问题 Normally using GDI+ in Delphi you can use a TPaintBox , and paint during the OnPaint event: procedure TForm1.PaintBox1Paint(Sender: TObject); var g: TGPGraphics; begin g := TGPGraphics.Create(PaintBox1.Canvas.Handle); try g.DrawImage(FSomeImage, 0, 0); finally g.Free; end; end; The problem with this paradigm is that creating a destroying a Graphics object each time is wasteful and poorly performing. Additionally, there are a few constructs availabe in GDI+ you can only use when you have a

Can I get a bitmap of an arbitrary window in another application process?

旧街凉风 提交于 2019-12-06 06:03:47
I am trying to automate a third-party Win32 application where I want to capture the graphics content of a particular window at defined time intervals. I am in the early phases of this, and I'm currently trying to use the Microsoft UI Automation API via C# to do most of the interaction between my client app and the external app. I can now get the external app to do what I want it to do, but now I want to capture the graphics from a specific window that seems to be some third-party owner-drawn control. How can I do this? The window I want to capture is the one marked by the red rectangle in this

Displaying Icons stored as resources with alpha using GDIPlus (WIn32 C++)

二次信任 提交于 2019-12-06 03:40:17
I have an icon with partial alpha (alpha values between 0 and 255) that I want to display using GDIPlus. When using the Bitmap constructor of GDI+ that takes the direct filename, the file displays properly. However, when loading from resource, it has a problem recognizing alpha. I looked on MSDN, and there are problems with alpha: http://msdn.microsoft.com/en-us/library/windows/desktop/ms536318.aspx . By retrieving the ICONINFO structure from the Icon, I can get rid of the fully transparent pixels, however, the partially transparent pixels still appear either as fully opaque or fully

.Net Inconsistent Font rendering

大憨熊 提交于 2019-12-06 02:30:09
I am creating an .Net 2.0 SP2 windows Forms Application. The form fonts looks fine in my machine, when i tried in another machine, it looks bigger. (This is not because of resolution difference, fonts are bigger relatively to other icons etc.) I tried to debug the problem and found following code returns different sizes on different machine. //inside a windows form private void checkfont() { var g = this.CreateGraphics(); MessageBox.Show(g.MeasureString("Hello World", this.Font) + "," + this.Font); } I expect graphics.measurestring() to return same value for same arguments in different

C# Console Application - How to draw in BMP/JPG file using GDI+?

匆匆过客 提交于 2019-12-06 00:24:34
I want to draw shapes like rectangles, arrows, text, lines in a BMP or JPG file, using a C# Console Application and GDI+. This is what I found on the web: c# save System.Drawing.Graphics to file c# save System.Drawing.Graphics to file GDI+ Tutorial for Beginners http://www.c-sharpcorner.com/UploadFile/mahesh/gdi_plus12092005070041AM/gdi_plus.aspx Professional C# - Graphics with GDI+ codeproject.com/Articles/1355/Professional-C-Graphics-with-GDI But this still doesn't help me. Some of these links explains this only for a Windows Forms Application and other links are only for reference (MSDN