gdi+

GDI+ Problem drawing a table

I try to draw a table on a panel in C# Windows Form by using GDI+. The problem is that when I minimize the application, my drawing disappears. How can I avoid this and why acting this way? ...

Draw Bitmap with alpha channel

I have a Format32bppArgb backbuffer, where I draw some lines: var g = Graphics.FromImage(bitmap); g.Clear(Color.FromArgb(0)); var rnd = new Random(); for (int i = 0; i < 5000; i++) { int x1 = rnd.Next(ClientRectangle.Left, ClientRectangle.Right); int y1 = rnd.Next(ClientRectangle.Top, ClientRectangle.Bottom); int x2 = rnd.Ne...

Need GDI programming Guideline

I want to change my window design rapidly. I have OnPaint function which I am calling when WM_PAINT message received. The design change only when the event occure. I want that design should automatically update doesn't depend on event kindly guide me how can I make it possible. ...

How can I overwrite a System.Drawing.Bitmap onto an existing GDI bitmap?

If I have a .Net Bitmap, I can create from it a GDI bitmap by calling the Bitmap's GetHbitmap() method. Bitmap bmp = new Bitmap(100, 100); IntPtr gdiBmp = bmp.GetHbitmap(); This works fine, but every time you call GetHbitmap, Windows has to allocate the new memory that the returned IntPtr references. What I'd like to do - if possib...

C#: Creating an editable object inside a PictureBox

My goal is to let the user click on a specific location on a map to add a Placemark, and then edit the placemark by click its icon (change its name, move it around, etc). I am using a PictureBox to show the map, and by registering the MouseDoubleClick event I am drawing an Image on the map with GDI+ DrawImage() method. The problem is tha...

Some images fails to load on Windows Server 2008

I have an application running on a Windows Server 2008, that is processing uploaded images. Currently it successfully processes about 8000 images per day, creating 11 different sizes of each image. The problem that I have is that sometimes the application fails to load some images, I get the error "System.Runtime.InteropServices.Externa...

GDI+ on 64bit systems

Our system uses a lot of large Bitmaps (System.Drawing.Bitmap) and sometimes we run out of memory and gets a "Parameter is not valid" error. This makes sense, since it can be difficult to allocate large continuous chunk of memory. So the question is... If we upgraded the system to 64bit, would this problem go away? ...

Creating a image viewer window controll.

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 reco...

Invert the 1bbp color under a rectangle.

I am working with GDI+, the image I am working with is a 1bbp image. What i would like to do is draw a rectangle on the image and everything under that rectangle will be inverted (white pixels will become black and black pixels become white). All of the sample code I have seen is for 8 bit RGB color scale images, and I don't think the t...

GDI+ DrawImage function

There is something I am missing. Say I have the following code: private Bitmap source = new Bitmap (some_stream); Bitmap bmp = new Bitmap(100,100); Rectangle newRect = new Rectangle(0, 0, bmp.Width, bmp.Height); Rectangle toZoom= new Rectangle(0, 0, 10, 10); Graphics g = Graphics.FromImage(bmp); g.DrawImage(source, newRect, toZoom, Gra...

GDI+ Problem encountered in drawing multiples rectangles on the form

I whant to draw a table in C# Windows Forms using GDI+. When the number of rectangles is too large for all rectangles to be displayed on the form, it does not scroll. And can not access those who did not fit the form. What I need to do to see everything I drawing on the form? Thanks. ...

GDI+, Smaller images ?

I create a bitmap from bytes coming via the web and when I downsample it, the resulting Jpeg is still too big even though I use small pixel format. Does someone know how to manipulate the compression of the image? I had the impression that the saved image is no longer compressed. ...

Controlling the visibility of a Bitmap in .NET

Hi everyone, I am trying to create this simple application in c#: when the user double clicks on specific location in the form, a little circle will be drawn. By one click, if the current location is marked by a circle - the circle will be removed. I am trying to do this by simply register the MouseDoubleClick and MouseClick events, an...

Problem using GDI+ with multiple threads (VB.NET)

I think it would be best if I just copy and pasted the code (it's very trivial). Private Sub Main() Handles MyBase.Shown timer.Interval = 10 timer.Enabled = True End Sub Private Sub Form1_Paint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint e.Graphics.DrawImage(image, 0, ...

DrawImage in XP Mode or Remote Desktop

I'm displaying a PNG with a transparent background that looks good in Windows 7, but then I run my app in XP Mode or remote desktop to a Windows XP machine and the PNG looks incorrect. I noticed that if I disable "Integration Mode" or run the app on XP without remote desktop, the image looks fine. How do I get DrawImage to render the PN...

C# winforms: graphics.DrawImage problem

Hi, I have a really strange problem with Graphics.DrawImage method. I have the PictureBox control in the Panel control with AllowScroll property = true. The program cuts the image on small parts basing on the area selected by the user. I load the image 300x547 and select the area (the red rectangle): program properly cuts the image:...

C# winforms: How to change DPI of the System.Drawing.BItmap ?

I need to change the DPI of the System.Drawing.Bitmap object from the default value = 96 to e.g. 150. I couldn't find the answer how to do that so I ask here :) ...

Graphics.MeasureCharacterRanges giving wrong size calculations in C#.Net?

I'm trying to render some text into a specific part of an image in a Web Forms app. The text will be user entered, so I want to vary the font size to make sure it fits within the bounding box. I have code that was doing this fine on my proof-of-concept implementation, but I'm now trying it against the assets from the designer, which are...

Mono Ignores Graphics.InterpolationMode?

I have a program that draws some vector graphics using System.Drawing and the Graphics class. The anti-aliasing works, kindof okay, but for my need I neede oversampling, so I create the starting image to be n times larger and then scale back the final image by n. On Window and .NET the resulting image looks great! However, on Mono 2.4.2....

GDI+ With C++Builder ?

How do I use GDI+ with C++Builder? Can someone give me a simple example of creating a surface and drawing a circle on it? ...