gdi+

Is it possible to BitBlt directly from a GDI+ bitmap?

巧了我就是萌 提交于 2019-12-03 03:40:54
Is it possible to use BitBlt to copy directly out of a GDI+ bitmap without using GetHBitmap? GetHBitmap is slow because it makes a new copy of the whole image, in addition to and slower than the BitBlt copy, and the given HBITMAP must be disposed. The image is large. Is there a way to point BitBlt to use the pixel data of the original GDI+ image? EDIT: I can get a pointer to where the GDI+ bitmap pixel data is in the memory. Can I create an HBITMAP that points to the GDI+ bitmap pixel data to avoid the extra copy, and BitBlt from that? jnm2 After searching for days, it suddenly hit me that the

A Generic Error occurred in GDI+ when calling Bitmap.GetHicon

久未见 提交于 2019-12-03 02:47:13
Why I'm getting "A Generic Error occurred in GDI+" Exception ? IntPtr hicon = tempBitmap.GetHicon(); Icon bitmapIcon = Icon.FromHandle(hicon); return bitmapIcon; The error occurred when my application has been running for more than 30 minutes. (I am converting System.Drawing.Bitmap to System.Drawing.Icon every second) Hans Passant That's caused by a handle leak. You can diagnose the leak with TaskMgr.exe, Processes tab. View + Select Columns and tick Handles, GDI Objects and USER Objects. Observe these columns while your program is running. If my guess is right, you'll see the GDI Objects

Rendering controls on glass: Solution found, needs double-buffering/perfecting

人走茶凉 提交于 2019-12-03 01:09:57
问题 I (finally!) found a way of rendering Windows.Forms controls on glass that doesn't seem to have any major drawback nor any big implementation time. It's inspired by this article from Coded, which basically explains how to natively override the painting of controls to draw over them. I used that approach to render the control to a bitmap and paint it back with GDI+ and the appropriate alpha channel over the NativeWindow's painting area. The implementation is simple but could be perfected for

What is the difference between CreateGraphics and a Paint event's Graphics object?

我与影子孤独终老i 提交于 2019-12-02 23:49:43
问题 Can someone explain the difference between the Graphics object that is passed as pevent.Graphics and the one that is returned by a call to this.CreateGraphics() ? 回答1: Whenever a Paint event is raised, you are given a Graphics object to draw into. This is passed as pevent.Graphics . Drawing into this Graphics object is how you paint the element. CreateGraphics should basically never be used. It creates a new Graphics object on-the-fly from a window handle. You can draw into the Graphics

About GDI/GDI+ coordinate compatibility?

人走茶凉 提交于 2019-12-02 22:40:33
I have a problem while drawing with both GDI and GDI+ interchangeably. The page transformation—in particular scaling—seems to be a little bit off between the two. Which properties of the GDI context affects the scaling of the output other than SetViewportExt and SetWindowExt ? The code uses almost exclusively GDI for its drawing, but uses GDI+ in a few cases where its features (semitransparency) are needed. It uses SetViewportExt , SetWindowExt and SetViewportOrg to enable zooming and scrolling. When GDI+ is needed I construct a Gdiplus::Graphics object around the HDC and do the drawing. I

How to stitch images with very little overlap?

寵の児 提交于 2019-12-02 22:03:02
I am trying to create a panorama using images with very little overlap, but I know the angle of the camera so I know exactly how much overlap there is and I know the order of the images so I know where each one belongs in the panorama. As a first pass I simply cocantenated the images together but the result is not good enough. Is there a way to crop the Bitmaps to trapezoids to eliminate (most of the) the overlap, then stretch the Bitmaps back to Rectangles before the concantenation? I know this will produce distortion during the stretching, and that a trapezoid is just a close approximation

Using custom TTF font for DrawString image rendering

折月煮酒 提交于 2019-12-02 20:35:58
I am using GDI+ on the server-side to create an image which is streamed to the user's browser. None of the standard fonts fit my requirements and so I want to load a TrueType font and use this font for drawing my strings to the graphics object: using (var backgroundImage = new Bitmap(backgroundPath)) using (var avatarImage = new Bitmap(avatarPath)) using (var myFont = new Font("myCustom", 8f)) { Graphics canvas = Graphics.FromImage(backgroundImage); canvas.DrawImage(avatarImage, new Point(0, 0)); canvas.DrawString(username, myFont, new SolidBrush(Color.Black), new PointF(5, 5)); return new

Fast multi-window rendering

ぐ巨炮叔叔 提交于 2019-12-02 19:33:25
I've been searching and testing different kinds of rendering libraries for C# days for many weeks now. So far I haven't found a single library that works well on multi-windowed rendering setups. The requirement is to be able to run the program on 12+ monitor setups (financial charting) without latencies on a fast computer. Each window needs to update multiple times every second. While doing this CPU needs to do lots of intensive and time critical tasks so some of the burden has to be shifted to GPUs. That's where hardware rendering steps in, in another words DirectX or OpenGL. I have tried GDI

How do I create a blurred-glass effect on a border-less Form?

强颜欢笑 提交于 2019-12-02 18:39:16
How do I draw a smooth blurred-glass effect on a border-less Form? I have tried the code listed on Image Processing for Dummies with C and GDI+ page but I'm sure it's not what I should be using. No amount of playing around with it has yielded any kind of result that is what I'm after. This is basically what I'm trying to achieve: I'll assume you are talking about Windows 7 / Vista, and you'd like to achieve the blurry transparent areas that some MS programs have in the same way. For the general case, you do need some image processing which I'm not going to cover. For the case I mentioned above

What is the difference between CreateGraphics and a Paint event's Graphics object?

霸气de小男生 提交于 2019-12-02 15:06:49
Can someone explain the difference between the Graphics object that is passed as pevent.Graphics and the one that is returned by a call to this.CreateGraphics() ? Whenever a Paint event is raised, you are given a Graphics object to draw into. This is passed as pevent.Graphics . Drawing into this Graphics object is how you paint the element. CreateGraphics should basically never be used. It creates a new Graphics object on-the-fly from a window handle. You can draw into the Graphics object it returns, but anything you draw into it will be obliterated the next time that a Paint event is raised.