gdi+

Why would StretchDIBits fail on turning image upside down when drawing to EMF file?

I'm attempting to draw an image using StretchDIBits with an Enhanced Meta File handle as the HDC to my OnDraw function using C++ and Visual Studio 2008. I load the .bmp source file using GDIplus and using GetHBITMAP. If I use the HDC returned by BeginPaint there are no problems. If I draw the bitmap upright, flipped horizontally, or fli...

Image.SetResolution results in A generic error occurred in GDI+

Hello! For some reason if I call on a 600 dpi image: myImage.SetResolution(72, 72) It gives me "A generic error occurred in GDI+". Moreover, if I try to create a new 72 dpi bitmap, create graphics object from that and use DrawImage to draw original 600 dpi image in the graphics object created from the new bitmap, I also get this err...

GDI+ doesn't throw exception, big red X

I am rendering stuff with a Graphics-object in a picturebox inside the Paint-event for that picturebox. void pictureBox1_Paint(object sender, PaintEventArgs e) { Graphics g = e.Graphics; g.FillEllipse(color, x, ...); etc etc...... } Everything works fine but suddenly the picturebox turns white and ...

Does System.Windows.Media.Imaging use DirectX (like WPF) or GDI+?

First I used SSRS to render a TIFF document and found out although it is possible to pass colour depth parameter to SSRS 2005 or 2008, it discards it and always generates a 24bpp file. Without luck, got this 24bpp file generated by SSRS render method, loaded it on a System.Drawing.Bitmap object and successfully scaled it to 1728 pixels b...

Error while loading JPEG: "A generic error occurred in GDI+."

I have some JPEG files that I can't seem to load into my C# application. They load fine into other applications, like the GIMP. This is the line of code I'm using to load the image: System.Drawing.Image img = System.Drawing.Image.FromFile(@"C:\Image.jpg"); The exception I get is: "A generic error occurred in GDI+.", which really isn't...

Improving GUI & Graphics

A picture for reference of the current state of the game: http://h.imagehost.org/0524/td.jpg I'm developing a simple 2D hobby (personal) game in C# that uses GDI+ for rendering since I decided that I would focus mostly on the gameplay, and not so much the immersion and graphics/UI. Now, however, I got most of the gameplay ready, and I w...

Transparent control over WM Player ActiveX component in .NET

I have a Windows media player activex component in my Form. On top of this WM player i have a picturebox with background color set to transparent. When i set an image for this picturebox , thought the image contains transparent areas it is displayed as black when the picturebox is above the WM player component. Where as if i place the P...

How to Convert GDI+'s Image* into Bitmap*

I am writting code in c++, gdi+. I make use of Image's GetThumbnail() method to get thumbnail. However, I need to convert it into HBITMAP. I know the following code can get GetHBITMAP: Bitmap* img; HBITMAP temp; Color color; img->GetHBITMAP(color, &temp); // if img is Bitmap* this works well。 But how can I convert Image* into Bitm...

Update before screenshot

I want to capture an image of the screen, however there are some wpf controls in my application that I do not want to appear in the screenshot. Using the code below, the hidden controls will sometimes still appear in the screenshot. How do I ensure that this doesn't happen? Window window = new Window(); Button button = new Button(); vo...

How to Convert a gdi+ Bitmap-like struct into an HDC?

How to Convert a Bitmap-like struct into an HDC? I am now writting image processing program in c++, gdi. If I got a HDC. I can draw whatever I like on the HDC in gdi by the following code. // HDC is handy. HDC dc; dc.DrawXXX // I can draw using gdi method. Graphics gr(dc); // now I can also draw on the dc using gdi+ method. My...

Is there a way to paint semi transparently on a PictureBox?

I use a transparent background for the PictureBox control. But I also want to be able to paint with a %50 opacity blue FillRectangle. How to do this? ...

Calculating a formatted string's width & height in C#

Hi, I am trying to generate a PDF using XSL(XML-FO) to transform a generated XML from a database. Because of complex rules in terms of paging for this document, calculations are done in determining the page breaks when I generate the XML that will be consumed by the XSL. I have noticed that I've been getting inconsistent results with ...

Image Property Tag Constant

I'd like to use the image property tag constants defined in GDI+ from .NET. I wonder whether these constant values (e.g. PropertyTagGpsVer constant) are exposed in any of the Base Class Library? I have tried looking around System.Drawing.Imaging namespace to no avail. ...

C# Graphics Newbie Question

Good Day, I have some small transparent gif images (under 100x100) and wrote the following code to iterate through all the pixels to give me the RGB values: private void IteratePixels(string filepath) { string dataFormat = String.Empty; Bitmap objBitmap = new Bitmap(filepath); int counter = 0; for (int y = 0; y < objBit...

How to use ClearType with double buffering on Compact Framework?

When I draw a string into a buffer, the resulting output is not anti-aliased the way I'd expect. This code illustrates the problem... just put this in a standard smart device project's Form1.cs: protected override void OnPaint(PaintEventArgs e) { Bitmap buffer = new Bitmap(Width, Height, PixelFormat.Format32bppRgb); using(Graphics g...

VB.NET control GDI handle leak?

I have a problem with a control leaking GDI handles. This is the cut-down version of the control: Public Class FancyLabel Inherits Label Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs) e.Graphics.TextRenderingHint = Drawing.Text.TextRenderingHint.ClearTypeGridFit MyBase.OnPaint(e) ...

How to copy a System.Drawing.Image value?

I am trying to copy an Image value to draw on it and on second draw ignore the last one and start over on top of the preserved Image value. I.e.: Image with 4 rectangle (ImageA) -> draw a circle return to ImageA -> draw a rectangle now there are 5 rectangles I don't know if it's the optimal way to draw too? ...

.NET : How to Create thumbnail from flash

Is there any way where i can create a thumbnail image from a flash movie file(flv /swf) [NOT FROM A VIDEO File ] in ASP.NET ? Any samples of implementation ? ...

Dispose question

When you have code like: Bitmap bmp = new Bitmap ( 100, 100 ); Graphics g = Graphics.FromImage ( bmp ); Pen p = new Pen ( Color.FromArgb ( 128, Color.Blue ), 1 ); Brush b = new SolidBrush ( Color.FromArgb ( 128, Color.Blue ) ); g.FillEllipse ( b, 0, 0, 99, 99 ); g.FillRegion ( b, pictureBox1.Region ); pictureBox1.BackColor = Colo...

How to judge whether two font are the same in GDI+

I am writing program in gdi+ c++. how can I know two Font* p1, Font* p2 are the same. p1 and p2 are points of different address. p1 p2 point to different object:) ...