Click here to Skip to main content
15,881,424 members
Everything / Multimedia / GDI

GDI

GDI

Great Reads

by Paul M Watt
Guide to understanding how to create and use regions with the WIN32 SDK
by Shao Voon Wong
Tracing GDI Leaks with Windows Debugger
by Hans Dietrich
XBreadCrumbBar is a windowless non-MFC class that allows you to display a breadcrumb trail as HTML text, with support for web links and APP: links.
by Keith Rule
Create visually complex, yet programmatically simple, non-rectangular GUIs

Latest Articles

by Shao Voon Wong
Tracing GDI Leaks with Windows Debugger
by Andy De Filippo
Render Rich Text with GDI+ by tapping into the power of API hooking
by AdventureDriver
Creating a optionally sheared mirrored image from a source image in a collage
by David O'Neil
Everybody Loves the Mandelbrot Set! Here's a browser for it!

All Articles

Sort by Score

GDI 

10 Mar 2002 by Paul M Watt
Guide to understanding how to create and use regions with the WIN32 SDK
25 Apr 2023 by Shao Voon Wong
Tracing GDI Leaks with Windows Debugger
7 Aug 2007 by Hans Dietrich
XBreadCrumbBar is a windowless non-MFC class that allows you to display a breadcrumb trail as HTML text, with support for web links and APP: links.
6 Feb 2000 by Keith Rule
Create visually complex, yet programmatically simple, non-rectangular GUIs
29 Dec 2006 by Michael Dunn
How to use power status notifications to make your applications conserve power when necessary.
29 Jun 2009 by Michael Dunn
Create custom tasks in your app's jump list on Windows 7
27 Mar 2001 by Joseph M. Newcomer
GDI objects selected in a DC can't be deleted - even when you call DeleteObject. This handy class makes these potential leaks a thing of the past.
8 Oct 2009 by Syed Hasan Hyder
This article focuses on internal supply chain management systems visibility via chart reports, and provides assessment apparatus to manage and monitor activities spawned during business processes, hence paves the way for timely and precise business decisions.
25 Jan 2013 by FatCatProgrammer
StarReport: WPF-less GDI+.NET report component.
10 Dec 2001 by Yuriy Zaporozhets
Very primitive function that creates region from *.bmp files
17 Jan 2021 by David O'Neil
Everybody Loves the Mandelbrot Set! Here's a browser for it!
15 Jul 2000 by Dave Lorde
Simple customised Window captions, including multi-line captions
29 Jun 2016 by The Zakies
we would create Hand_tool to pan through the drawing form, and we would use a custom cursor of open and closed hands
18 Jun 2012 by Mark Kruger
API which shows a Selection Overlay and notifies the caller when it's resizing and notifies the final rectangle.
27 Aug 2012 by Richard James Moss
This article describes adding design time support for a TabControl-like component which renders the same way the Project Properties in Visual Studio 2012.
6 Mar 2013 by wmjordan
Rendering text with OpenType fonts by P/Invoking GDI API in WinForm applications.
25 Jan 2015 by syed shanu
XBAR and Range Chart using C#
7 Aug 2016 by User 9149614
Preserving alpha channel drawing transparent PNGs
16 Mar 2011 by Albin Abel
Like HTML images, we can have clickable areas in a picturebox of windows application
5 Jun 2012 by Michael Banzon
Windows and GDI-objects
13 Sep 2012 by Jochen Arndt
Stock objects must not be deleted because they are part of Windows. As far as I know delete requests for stock objcets are ignored by Windows.
15 Aug 2013 by Chris Boss
OpenGL based 3D learning software
25 Jan 2016 by Samuel Teixeira
Why simple if we can be complex?
1 Mar 2017 by trident99
GtProject is intended to provide the user a Microsoft Project equivalent control to use for scheduling tasks.
29 Nov 2010 by Alain Rist
See the Scribble MFC sample[^].cheers,AR
9 Jul 2011 by DaveAuld
There is a technical blog article on the subject;Face Recognition Project: Introduction To Face Recognition[^]
29 Jan 2012 by Richard James Moss
This post describes how to create a GroupBox control similar to those used in Microsoft Outlook
12 Jun 2013 by Sergey Alexandrovich Kryukov
This is quite a complex problem, but I think you can solve it if you study the subject properly and put some decent effort. I hope you goals really worth the effort, and, additionally, you could potentially help many other people. So, thank you very much for your interest in this work and your...
20 Jul 2013 by m_kramar
MVC Complex model postback: bind field to JSON string
6 Nov 2013 by enhzflep
Okay then, well where to begin?I looked at this problem from a bunch of angles, I must've pondered and tried 1/2 a dozen combinations of approaches, but I think I've found one that is workable.Basically, the idea is to do all the drawing on the dialog/window itself and then use button...
29 Jan 2018 by Shao Voon Wong
Fixing Inconsistent Stroke Width of Chinese Characters
25 Jan 2010 by #realJSOP
You're allocating memory for the image. In order to do that, you need to allocate memory for each pixel and the desired color depth of that image. That's what the 32*32*5 does.
18 Apr 2010 by Cedric Moonen
Well, nobody's going to make the work for you. So, if you have no knowledge in C++, I suggest that you either hire someone or start learning it yourself (buy a book for instance).Now, to give some pointers for your question, you have to separate the two tasks: reading the data from USB and...
15 May 2010 by Richard MacCutchan
23_444 wrote:I'm not convinced ... that WM_PAINT is firing for each call.You are correct, these calls tend to get collected together and then the app gets a single WM_PAINT message for an accumulation of more than one of the invalidated regions. As to the advantages of doing it this way,...
26 Oct 2011 by markkuk
PLplot[^] or MathGL[^]
5 Nov 2011 by zenwalker1985
String to Integer conversion Internals
26 Dec 2011 by zoyobar
Binding and Handling JSON Field In jQuery Repeater
2 Apr 2013 by nv3
You did actually all that is necessary for your own coordinate calculation, assuming you leave the windows viewport in its native (text) mode. The two factors ScreenXSeconds and ScreenYGain are the factors with which you have to multiply the raw values. The names chosen are not to my liking, but...
18 May 2013 by Ron Beyer
See this:http://stackoverflow.com/questions/2473799/gdi-double-buffering-in-c[^]
12 Jun 2013 by R.Lohmueller
hello together,can anyone give me hints to (c++/mfc) source to construct an image with a moving webcam.my father has a debility of sight and I'd like to develop an application for him that "scans" a newsletter column while moving a webcam over it. I already get the image of the webcam...
15 Jun 2013 by Ron Beyer
CAD software doesn't use controls for each object/line/rectangle. You use one control called a surface and draw on that surface. You then do your own object management.There is a limit to the number of GDI objects a program can have, and using one object per line/drawing object will quickly...
10 Nov 2013 by enhzflep
There's just two changes you need to make. In each case, it's because you've forgotten that when drawing to the HDC of a control, the RECT always has the top and left members set to 0.However, when drawing this rect onto the background of the dialog, the top and left members are no longer...
3 Dec 2013 by Sergey Alexandrovich Kryukov
Flicker can be in part caused by the Windows message WM_ERASEBKGND which you can handle to do nothing, as explained here: http://stackoverflow.com/questions/2473799/gdi-double-buffering-in-c[^] (see answer 3).A widely used "brute-force" way of removing flicker is the use of optimized double...
18 Dec 2013 by AlwaysLearningNewStuff
INTRODUCTION AND RELEVANT INFORMATION:The original project I work on has small memory leaks, so I have decided to perform a small test so I can detect what could cause them.I have created a Win32 project using Visual Studio wizard. I haven't added anything, I have just left it as it was...
23 Dec 2013 by Codexzy
I have a rectangle which is drawn in the WM_PAINT message. Now I want to simulate this rectangular portion like a button. When I bring the mouse cursor into the rectangular area its background color should be changed and when i bring the cursor out of it it should be in its original...
11 Dec 2015 by CHill60
Have a look at this CP article Professional C# - Graphics with GDI+[^]There is also a reference zone[^] here on CPOr there always the M$ documentation[^]
26 Jun 2017 by OriginalGriff
Quote: I just don't have the patience to sit down with pen and paper and figure out exactly how to render all the elements using GDI Then I suspect that this app isn't going to happen: if you can't be bothered to do the work, why would you think we would want to do it for you? If you want...
26 Jun 2017 by F-ES Sitecore
This should hopefully get you started static void Main(string[] args) { // 120 x 120 thumbnail Bitmap image = new Bitmap(120, 120); Graphics g = Graphics.FromImage(image); g.Clear(Color.White); Pen p = new Pen(Color.Black, 3); // Primary display g.DrawLine(p,...
19 Sep 2020 by Richard MacCutchan
The only thing I can see that may be an issue is the following: FillRgn(hdc, hrgnClip, CreateSolidBrush(color)); DeleteObject(SelectObject(hdc, GetStockObject(WHITE_BRUSH))); Are you certain that DeleteObject is actually deleting the solid brush?
20 May 2002 by Jason Henderson
Draw and animate ASCII characters to a window using this COM object.
2 Sep 2008 by Uri91
Hello,I'm a high-school student seeking to learn about 3D programming. I have experience with C# and C++, OOP and more.I don't have any intentions of making high-grade stuff with 3D, but I do want to learn something that I might use in the...
2 Sep 2008 by John_Adams
Hi,I would suggest you to visit the following links to know the difference between WPF, DIRECTX and XNA.http://forums.xna.com/forums/t/5278.aspx[^]http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=257213&SiteID=1[^]Hope this helps ...
18 Sep 2021 by Storm Kiernan
This code is giving me problems: private void SaveBMP(Bitmap bmp) { bmp.Save(_project.MapFilePath); }This line throws a generic GDI+ error.bmp.Save(_project.MapFilePath);Any ideas?quote:It means that the file path points to an image that...
16 Jan 2010 by Christian Graus
It means that the file path points to an image that has already been opened in GDI+. You need to be careful to close your images when you are done with them. There's tons of info on this on the web, but that's the core of all the info you'll find. Bugs in GDI+ cause it to hold a file open,...
17 Jan 2010 by Christian Graus
Sure - that means that the image that was being held open, was the one that you were working with, which is not surprising.
3 Mar 2010 by The Man from U.N.C.L.E.
Could be to do with the installed service packs..Net Framework Version 2.0 with Service Pack 2 is the latest version, and fixes all sorts of stuff. It Requires Windows 2000 SP4 on Windows 2000 plus the KB835732[^] or KB891861[^] updates.Even with all this installed there may still be...
18 Apr 2010 by #realJSOP
Check out rent-a-coder. They have people there that love working for almost nothing.
20 Apr 2010 by CPallini
You may create at once a resized bitmap instead of stretching again and again the original one. See if my "Plain C Resampling DLL"[^] article helps. :)
14 May 2010 by 23_444
I need to invalidate different areas on a screen at the same time (occurring in the same function).I could invoke the InvalidateRect(&rc) for each area:InvalidateRect(&rc);InvalidateRect(&rc2);or I could create a region and add the rectangles to the region and then use...
18 May 2010 by xspitfirexx
I am working on a mouse gesture recogniser and I am pressing right click and drawing with pencil tool all over my desktop. When I release it the drawing is still there and I need to use InvalidateRect() function to remove it. But it flickers like when you press Refresh. Is there a way to...
31 Aug 2010 by helianthus87
Do you asking about some math to calculate angle between 2 vectors to check the arc? You mentioned about 3 points and i asume there is something like this:[how do i see this]then you need to calculate angle or check dot product between 2 vectors and according to result you will be able...
17 Sep 2010 by CDP1802
A quick search on Google(!) led me to this article here:Adding GIF-animation using GDI+[^]
5 Oct 2010 by ely_bob
Use XNA, this has all the stuff that you need without going into the 3d portion of the API..and in the long run if you want to do things like sparkles, music, explosions.. or whatever else to augment your game you would have easy access to that stuff through XNA.GDI, and it pains me to...
4 Nov 2010 by tlillys
I'm attempting to extend an unmanaged VC++ 6.0 OCX that uses GDI for displaying images and drawing simple graphical elements - lines, points, and rectangles. I am trying to add translucent polygons on top of these elements. Based on articles found here, I believe I've made the code GDI+...
24 Nov 2010 by CDP1802
Nothing against XNA, but WPF would be better for this. A card game may need not much of a GUI, but some may be needed and that would be a pain, especially for somebody who just got started.With WPF you get the user interface and also the cards (including transformations) with far less overhead.
30 Nov 2010 by #realJSOP
Look at the scribble sample project provided by microsoft.
30 Nov 2010 by strogg
Of course, it happens. You must record actions and re-draw on WM_PAINT (OnPaint in MFC)If the painting actions are complex & cannot be recorded (like hand drawn shapes instead of lines, rectangles etc) You may draw into an offscreen memory DC (CDC::CreateCompatibleDC in MFC - imagine that as a...
3 Jan 2011 by Kasson
You need timer, and use that in tick event, set the co-ordinates of the rectangle and validate the form.
27 Jan 2011 by Bezawit
Hi. I am using a UserControl to display a picture. My application has a Zoom In/Zoom Out feature. I can press the Zoom Out button any number of times and the background code I write will make sure that the left side of the picture would not leave the left side of the UserControl it is drawn...
28 Jan 2011 by Espen Harlinn
GDI+ lets you draw using argb colors. the 'a' part lets you work with transparency. a=0 -> transaprent, a=255 -> opaque.See GDI+[^] for more information.RegardsEspen Harlinn
26 Feb 2011 by Sergey Alexandrovich Kryukov
All correct. See this discussion for explanation on how to get rid of this effect called flickering: http://stackoverflow.com/questions/197948/reduce-flicker-with-gdi-and-c[^].—SA
27 Feb 2011 by mbue
The hint of "Hans Dietrich" is right, because the call GetDC gets the window dc adjusted to screen coordinates. you can use them if you want to paint the non client area of the window (WM_NCPAINT). to paint within the client area you have to use BeginPaint and EndPaint. thats the clients update...
25 Apr 2011 by Olivier Levrey
In my opinion, you shouldn't do image processing directly on bitmaps. You should use bitmaps when loading from a file, displaying on screen, and saving to a file. Your filters should work on the pixels, whatever format they are.I suggest your filters work on BYTE or float array, or RGBQUAD...
1 May 2011 by Sergey Alexandrovich Kryukov
This is not an Explorer but the Shell subsystem. If you do it correctly, every software product using Shell API will show icons correctly.All you need is to create a correct icon and use it at least in two places: application icon and main windows icon (in principle, the icons for different...
8 May 2011 by Alain Rist
Hi Quy,The Gdiplus::Bitmap object by itself produces no new data, it is just a connector to the relevant codec and the Gdiplus::Image data (your IStream). When you succesfully call pBitmap->GetHBITMAP(Color(0,0,0),&hBitmap); the Gdiplus::Image data are read (from your IStream) and a...
22 Jun 2011 by Mahdi Nejadsahebi
hi babyhave a good timei'm iranian like you!well if you load and display that in mfc class(dialog) you shoud do these:1st:load atlimage.h for using the CImage,that's really usefull.#iclude "atlimage.h"2nd:define a global CImage.you shoud define that before OnInit...
9 Jul 2011 by thatraja
Addition to Dave's answer.Found a bunch in CPHuman Emotion Detection from Image[^]Pupil or Eyeball Detection and Extraction by C# from eye image[^]Face Detection in C#[^]Face and Eyes Detection Using OpenCV[^]Efficient Face Detection Algorithm using Viola Jones method[^]Face...
22 Sep 2011 by J_T
I need help converting a 1bpp windows Bitmap to a DIB IntPtr, but using the following code produces a DDB. Dim bm As New Bitmap("C:\test.jpg") Dim hBitmap As System.IntPtr = bm.GetHbitmap ImgMod(hBitmap, 27) ' Third party Function looking for a IntPtr to a DIB Currently the...
30 Nov 2011 by Manoj K Bhoir
Try the following link :A Vector Type for C#Or Check following Code :VB.Net Code :Public Shared Function ON_3dVectorAngle(ByVal v0 As On3dVector, ByVal v1 As On3dVector) _ As Double ' Unitize the input vectors v0.Unitize() v1.Unitize() Dim dot As Double =...
6 Dec 2011 by JackDingler
Do you mean you need to rotate an image? Use OpenGL and let your GPU do the work.If you're writing high performance image processing software, then I'd recommend that you learn OpenGL or DirectX and one of the GPU Technologies like OpenCL, DirectCompute, and or CUDA.CUDA seems to be the...
19 Dec 2011 by Richard MacCutchan
Short answer: Yes.Longer answer: See the remarks section here[^]. GDI objects consume system resources so not returning them after use could result in your system being unable to satisfy a request, and your program could then produce the wrong results, or fail completely.
13 Apr 2012 by Misol1
Hello all, We started to encounter a bizzare problem with TAdvGlassButton buttons from TMS Software under Delphi2007. Sometimes they simply do not show, and if so, then all of them, across whole application. The point is, that the buttons are there, they react to events (you have to know...
2 Jun 2012 by nv3
I have no experience in WinCE, but I would use CDC::Polygon, which automatically fills the polygon with the current brush. So create a brush with the same color as your solid pen, select it into the DC and then draw a polygon with the three points of your triangle. (Of course you know that a...
12 Jul 2013 by Abdelrahman Ismaeel Hegazy
Save image map portions for any image for later using in web or in printing using an image.
5 Feb 2013 by Lars [Large] Werner
Use the standard GDI API to load an HBITMAP into SFML.
14 Apr 2013 by sanoopdas
Hi,I am creating and deleting MFC gdi objects and watching the number of GDI Objects that application uses via Windows Task Manager.When i create a CBrush object by CreateSolidBrush i observe an increment in GDI Object count of application. However when i delete the brush by DeleteObject...
15 Apr 2013 by Jochen Arndt
As far as I know, the memory of solid brushes is not always freed when calling DeleteObject() but reserved and reused with following CreateSolidBrush() calls by simply replacing the color value. This can be verified by calling GetGuiResources() before and after creation and deletion. In some...
26 May 2013 by Ian A Davidson
I'm afraid I don't think it's necessarily that easy - The information available to you is only what the driver(s) provides.I think my first step would be to try getting HORZRES and divide by HORZSIZE and see if that gives you a different and/or gives you a correct line width (it will give...
27 Aug 2013 by Praveen Kumar Katiyar
Returning a string from a Win32 DLL using Interop.
10 Nov 2013 by AlwaysLearningNewStuff
INTRODUCTION AND RELEVANT INFORMATION:I want to create a static control with gradient background.I want to do it the following way:Create the gradient at the main window’s background, and then place transparent static control on top of that background.To do that, I have created...
17 Nov 2013 by Sergey Alexandrovich Kryukov
You certainly need to use double buffering. The only one method to accelerate things is to calculate some subset of the points of your window area, only those really touched by your most recent change in data, and call InvalidateRect or InvalidateRegion. You can combine any number of different...
5 Dec 2013 by AlwaysLearningNewStuff
The problem was in SetWindowPos API.I am quoting the developer who helped me to solve this problem:" When the main window is resized the WM_SIZE handler moves the static child windows.When a child window is moved, Windows automatically copies the client area of the child control from...
18 Dec 2013 by AlwaysLearningNewStuff
I do not wish to steal other people's credits so I post here a link to the answer that I think explains really well what is the problem:http://stackoverflow.com/questions/20664677/default-win32-project-has-constant-number-of-memory-leaks[^]
16 Jun 2014 by Richard MacCutchan
Take a look at GDI Drawing and Printing[^].
16 Jun 2014 by Richard MacCutchan
I have discovered that the issue is to do with the default unit settings in the Graphics class, as described in http://msdn.microsoft.com/en-us/library/ms535812(v=vs.85).aspx[^]You need to use the following line of code to set it to pixels.g.SetPageUnit(UnitPixel);That now works in XPS...
29 Nov 2014 by BillWoodruff
Using the default 'MeasureString and 'DrawString: leading-space and trailing-space may be automatically added when the string is rendered:"The MeasureString method is designed for use with individual strings and includes a small amount of extra space before and after the string to allow for...
28 Apr 2015 by Sergey Alexandrovich Kryukov
Before starting to deal with any runtime issues, throw out this code and write it in human way. Look at the two first lines inside the implementation of LoadImgFromGDIP: you call LoadLibrary again and again with the same DLL. This is not yet a reason for some runtime failures, but this is more...
8 May 2018 by Dave Kreskowiak
Seriously? You want someone to generate coordinates for 7 points for you? How about this. You generate them. It's easy. Grab a piece of paper, a pencil, and a ruler. Draw your lightning shape on the paper. Measure the width of the shape. The top left is going to be 0,0. The top right is going...
8 Jul 2020 by Dave Kreskowiak
It's capturing exactly what your code is telling it to capture. You have no choice but to run this code under the debugger, examining variables to make sure the values are what they are supposed to be. The code isn't doing what you think it's...
19 Sep 2020 by Patrice T
your code is very simple minded, and it is bad. Quote: i use Timer which redraws the digits every 100 milliseconds. A simple test can divide by 10 the workload of redraw: if (LastTime != NewTime) { redrawClock(); LastTime = NewTime; } ...