Click here to Skip to main content
15,889,931 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 Updated

GDI 

13 Nov 2023 by zhivot
I am converting between GDI (Win32 API) and different drawing format that also supports text and glyph rotation. Text output in GDI is specified with a reference point (and vertical alignment), but it is easy to take that into account when the...
25 Apr 2023 by Shao Voon Wong
Tracing GDI Leaks with Windows Debugger
14 Oct 2022 by Andy De Filippo
Render Rich Text with GDI+ by tapping into the power of API hooking
11 Apr 2022 by AdventureDriver
Creating a optionally sheared mirrored image from a source image in a collage
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...
17 Jan 2021 by David O'Neil
Everybody Loves the Mandelbrot Set! Here's a browser for it!
2 Dec 2020 by Member 14872681
Hello. I'm a developer who needs help. First of all, I hope you understand that the sentence structure can be strange as I ask questions using a translator machine. I am currently working on a program that requires watermarking on any...
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; } ...
19 Sep 2020 by Avtem
So i'm trying to create a digit clock using only WinAPI with C++ (see the screenshot)[^] Function drawDash() is called 7 times to draw one digit. i use Timer which redraws the digits every 100 milliseconds. Everything looks fine, but for...
19 Sep 2020 by Rick York
Since you are using C++, I recommend writing a class to handle this for you. Here's one possibility : template class handleobj { public: handleobj( T h ) { m_handle = h; } virtual ~handleobj() { if(...
19 Sep 2020 by KarstenK
Your problem is here:FillRgn(hdc, hrgnClip, CreateSolidBrush(color)); in creating a brush and NOT deleting it. Asign it to a var use it and than delete it later, or if the color is constant you need to create it only once. Your error case is...
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?
15 Aug 2020 by Mohammad Dehghan
Creating special 'Graphics' objects to draw anywhere on your window, including non-client area
8 Jul 2020 by MyOldAccount
I have created a small demo app which window looks as below: https://i.stack.imgur.com/iW05q.png[^] When I run this demo app, and press any key, I want to capture the part of the screen bitmap. The part of the screen I am interested in, is the...
8 Jul 2020 by KarstenK
You should respect the scaling how Richard wrote and also deal with multi monitor system. Some years ago I wrote an Repositioning Windows on Multiple Monitor Systems article which deals with that issue. But nevertheless your foo function looks...
8 Jul 2020 by Richard MacCutchan
See GetScaleFactorForMonitor function (shellscalingapi.h) - Win32 apps | Microsoft Docs[^].
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...
21 Apr 2020 by Yuksel YILDIRIM
Draw Multi Parametrik Shapes in 2D
3 Mar 2020 by LeisureBamboo
Randomly read any embedded_mono_matrix in TTF file, export it to bitmap files (in package)
23 Feb 2020 by Rick York
I recommend writing what I call an enumerator applet. Here's a screenshot of one I wrote for system colors. I have written several of these but I had done this one yet and your question inspired me. Screenshot at ServImg.com[^] My point is,...
23 Feb 2020 by deXo-fan
Hello, I wish to manually draw what looks like a window caption during the WM_NCPAINT event. I've made some progress, but I can't seem to get the color right. It's not the same as, say, Notepad's caption bar background color, which is RGB(0,...
22 Feb 2020 by Gerry Schmitz
If I want to know a color, I take a screen shot, paste it into Paint.NET (or something similar) and use their eye dropper / color palate. The color palate gives the RGB settings for the selected color. Visual Studio's "image editor" also gives...
2 Nov 2019 by Alaa Ben Fatma
Use your skills as a designer to create gorgeous control
1 Apr 2019 by SolarNigerija
I have 16-bit packed RAW GRAY SCALE images.each image may have different high bit, for example: 9,11,13, or 15 (10,12,14, or 16 bits per pixel respectfully). Building and using image statistics I can calculate min/max pixel values, and expand dynamic range of image to 16-bit per pixel/or using...
1 Apr 2019 by SolarNigerija
To conclude the story. WPF, DX, or anything else first needs Hardware (Graphics card+Driver) for displaying anything beyond 8-bit gray-scale (unless we use software fallback which we do not). So generally speaking we need to query hardware support for bit depths beyond 8-bit gray-scale. And...
1 Apr 2019 by veen_rp
Smooth a 2D polyline through interpolation (Catmull-Rom) or approximation (Chaikin)
18 Nov 2018 by XTAL256
Hello, I have some code that uses GDI+ to convert an icon to grayscale*. However, when transparency (i.e. alpha channel) is involved, the resulting icon seems to use pre-multiplied alpha - rather than normal alpha - making the transparent pixels look darker. * Create GDI+ Bitmap from HICON,...
7 Oct 2018 by Mojtaba Hosseini
A graphical binary tree. Features: add, remove, or search for a node. Recursive algorithm has been used
4 Oct 2018 by TwinLane
A non rectangular/transparent splash screen control that starts life before the Application Form
25 Jul 2018 by Alexandru Matei
Shows an alternative to GetCharABCWidths and GetCharABCWidthsFloat
8 May 2018 by BillWoodruff
Like this one 🗲 or this one 🗱 or 🌩 ... these are characters in the Windows Webdings font: [^]. You can easily scale these up, and take a screen shot, and then create ... whatever. Or, you can take a Label Control whose text is the symbol, set its 'BackColor to 'Transparent, and then set its...
8 May 2018 by SuperMiQi
Hello Everyone, I am looking for the small snippet c# code to draw a lightning bolt symbol. To give you an idea, I am looking for the code the generate this kind of image: lightning bolt. Even a non filled in lightning bolt symbol would be great. Thank you very much in advance. Best regards....
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...
29 Jan 2018 by Shao Voon Wong
Fixing Inconsistent Stroke Width of Chinese Characters
11 Jan 2018 by Jesusfan
Create a draggable, proper splash screen in DotNet, with gradient transparency!
14 Jul 2017 by Member 11346124
I find .Net Theme Created using GDI+. i am looking for Creating theme using GDI+ C++. where can i find tutorial. i Googled it but i only find draw line and such which are not i am looking for or i guess i need tutorial or help. Any suggestion or guide highly appreciated! ThanksWhat...
14 Jul 2017 by KarstenK
At first a theme is an installation package with some defined content. Her you find the Theme File Format described from Microsoft. Developing an own theme is a big task. I think the basics are handled in the in the outstanding article Custom Controls in Win32 API: Visual Styles and some good...
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,...
26 Jun 2017 by dandy72
Hi all, Has anyone ever looked at programmatically recreating the monitor layout as shown by the Display Settings dialog box in Windows? I'm talking about the screen that shows all your monitors, and how they're positioned relative to each other. On Windows 10, you get there by right-clicking...
26 Jun 2017 by Dave Kreskowiak
Quote: My question: Has anyone ever tried to use those values to render an Image from them? Obviously I wouldn't want something that's 1:1; a small-ish thumbnail is all I'm after. Bonus if it can display coordinates at each monitor's top-left/bottom-right corners and identify them by name...
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...
3 Jun 2017 by Regg Fulton
In my app I paint rectangles on a picturebox in diferent locations. I can drag them around with the mouse and even rotate them with the mouse wheel. At first I used pictureboxes, but rotating them became a hassle, so I created my own class instead. My class holds the drawing point points of...
3 Jun 2017 by Regg Fulton
Never mind. I solved the problem. The solution was ridiculously easy. I did away with ptrRegion(sx) = rgn.GetHrgn(g) instead keepig the region and a pointer to the region as properties in my class called BorderRegion and BorderRegionPtr. Then replace this Dim rgn As System.Drawing.Region...
18 May 2017 by darkoman
Article about the 2D isometric game engine
29 Mar 2017 by Taehoon Kim 1004
Capture program using GDI
1 Mar 2017 by trident99
GtProject is intended to provide the user a Microsoft Project equivalent control to use for scheduling tasks.
1 Mar 2017 by Member 12677926
i am converting my code from vb to c++ there are some dynamic points which are there to draw different shapes.in vb they have properties such as .ScaleWidth, .ScaleHeight, .ScaleTop , .ScaleLeft.what they had done is they had scaled according to width and height using these properties ...
1 Mar 2017 by KarstenK
With C++ and MFC you have the power and responsibility to draw each pixel for yourself. For that you must scale what you want to draw in the drawing rectangle. There are two way:1. scale the content coordinates before drawing them (recommanded for your DrawLine)2. draw an offline...
13 Feb 2017 by trident99
GT is a compact, efficient, and customizable graphical user interface (GUI) library for the Windows environment.
12 Dec 2016 by Farhad Reza
A simple graphics class for 2D drawing
6 Nov 2016 by yetibrain
Unicode Buddy is a tool to inspect unicode files. It can detect orphaned surrogates and invalid utf-8 sequences. It is able to show the encoding/decoding of a certain codepoint. It is not an editor but a viewer.
29 Oct 2016 by OriginalGriff
Find a tattoo site and ask there.This is a software development site and we are not body modification experts.Or talk to the tattooist / your doctor / emergency medical people.
12 Oct 2016 by gricardi
As users are migrating from traditional desktops to mobile devices, transitioning your Windows application to the web is the next step to increasing your exposure. Thinfinity VirtualUI delivers your Windows applications to users on any device, anywhere.
26 Aug 2016 by Javad Taheri (drjackool)
Creating Simple PNG Decoder/Encoder
23 Aug 2016 by Alaa Ben Fatma
Inherits the awesome style of Visual Studio's TabControl for better exploiting
7 Aug 2016 by User 9149614
Preserving alpha channel drawing transparent PNGs
3 Jul 2016 by The Zakies
we will continue the functionality of the hand tool with having a navigator panel which works as a map, we will also have a red rectangle which tells the user where he is actually viewing inside the whole form, also it can be moved to pan the form
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
24 Jun 2016 by The Zakies
in this tut we will create a technique to enable the user to control points within a drawn line, by drawing circles around points of the line , when the user clicks a circle he would control the corresponding point.
18 Jun 2016 by Patrik Mlekuž
Image Control for viewing most common image formats with advanced features included (Import Image, Preview, Resize, Position, Pan, Zoom, Export Image, Extract Resource Icon).
7 Jun 2016 by The Zakies
[tut4] how to draw lines & to draw different types on end shapes like rectangle and circle using C#
12 Apr 2016 by Shao Voon Wong
How to use a font without installing it first on user systems
7 Apr 2016 by The Zakies
Part 3 of a tutorial to show a graphics program using C# using GDI and SVG drag and drop and delete objects
29 Feb 2016 by mOOmOOn_
Hi,I developped an application capable of playing video with DirectShow and scrolling text with layered windows. Text is drawn using GDIPlus.I remarked text was sometimes stuttering when using EVR renderer.I could point out that stuttering occurs exactly during the RenderFile method...
25 Jan 2016 by Samuel Teixeira
Why simple if we can be complex?
16 Jan 2016 by Mathew_wwx
This tip will introduce a library written in C++ that wraps up a 2d polygon triangulation algorithm with time complexity of O(N*logN), the algorithm works on both self-intersected and non self-intersected polygons.
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[^]
11 Dec 2015 by Umut Comlekcioglu
Hello everyone,I'm developing Puzzle Game for my little brother. I wanna drawing Puzzle Piece like below. http://postimg.org/image/q5j410d3p/[^]I can't use Bitmap or Picturebox. So I need to draw it with Graphics Path but I don't know too much about Graphics Path.Anyone can help...
21 Nov 2015 by zenwalker1985
Dear Reader, I would like to bring into your attention an old article written on this topic. This article explains alot about strings concatenation and does very good performance analysis. Here is a glimpse about this article: Over the years, plenty has been written about... Read More
14 Oct 2015 by Farhad Reza
Here, we will design a clock frame with Assembly Language and GDI32
12 Sep 2015 by rezaasaadi
I use GDI functions to render vector data for many years,even after migration to C# and dotNet,I still use GDI libraries because I found GDI much faster than GDI+ in vector rendering.Now I have stuck in a problem where I have to use GDI+ and face a problem.My vector coordinates are in real...
11 Sep 2015 by Johnny J.
A ToggleSwitch that presents on/off values in a more interesting way than a standard CheckBox
8 Sep 2015 by Farhad Reza
A simple ChessBoard graphics using GDI32
5 Aug 2015 by sreeyush sudhakaran
VB.NET code for Base64 Encoding and Decoding of Image files
26 Jul 2015 by Petr Bříza
This app helps you with understanding and using GDI DrawString function: precise measuring, positioning, quality setting and performance tuning.
1 Jul 2015 by Member 11806482
I am creating a screen capture application which can capture presently running application on desktop (be it a fullscreen game or a video or simply desktop) and render it onto an external monitor.I read various questions on stackoverflow and refered different blogs about screen capture using...
14 Jun 2015 by Sergey Alexandrovich Kryukov
No, don't fill closed curve; instead, build and fill the region:https://msdn.microsoft.com/en-us/library/system.drawing.graphics.fillregion%28v=vs.110%29.aspx[^],https://msdn.microsoft.com/en-us/library/system.drawing.region%28v=vs.110%29.aspx[^].—SA
14 Jun 2015 by Member 8727660
I want to fill region between two lines in in a c# graphics using c#.i'm using drawlines method to draw the two curvespoints.Add(new PointF(x + left, (float)y + trackHeight));...if (points.Count > 1) { using (Pen pen = HandlerGraphs.GetPen(log.LineStyle, log.Brush,...
25 May 2015 by Raje_
You can try these :http://stackoverflow.com/questions/25796669/draw-a-graphicspath-in-a-pdf[^]http://www.mikesdotnetting.com/article/88/itextsharp-drawing-shapes-and-graphics[^]Good luck :)
25 May 2015 by Member 8727660
i want to draw a Curve (image) in a Pdf document using itextSharp, how can i pass automatically to next page?
28 Apr 2015 by Richard MacCutchan
Don't use LoadLibrary, link all standard libraries into your application, that will ensure that you get the correct versions. And you should not be using plain C to use GDI+ as it is an object based system: see http://msdn.microsoft.com/en-us/library/ms533798(VS.85).aspx[^].You are also...
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...
28 Apr 2015 by Member 11643863
void LoadImgFromGDIP(){ GdiplusStartup GDIPStart = (GdiplusStartup)GetProcAddress(LoadLibrary(TEXT("gdiplus.dll")), "GdiplusStartup"); GdipCreateFromHDC GDIPCreate = (GdipCreateFromHDC)GetProcAddress(LoadLibrary(TEXT("gdiplus.dll")), "GdipCreateFromHDC"); GdipLoadImageFromFile...
10 Apr 2015 by hisham ahmed
Bitmap newBmp = new Bitmap(bmp);bmp.Dispose();newBmp.Save("yourPath");MessageBox.Show("Saved");
23 Mar 2015 by Novar Striker
Multi technics in one application, for an extreme relaxation moment
22 Mar 2015 by Sergey Alexandrovich Kryukov
I've done this screen-independent layout (with and without zoom) many times and never had problems.There are few simple rules you can check.Look at your design-time generated form code (as C# source) and find all immediate constants of integer types. You should not find a single one that...
28 Jan 2015 by syed shanu
Animated Image Slide Show for Winforms using C#
27 Jan 2015 by syed shanu
USL/LSL Control Chart using .NET for Quality Control
25 Jan 2015 by syed shanu
XBAR and Range Chart using C#
23 Jan 2015 by Pikoh
I've a problem i've been struggling with for some days.I've got a DataGridView, and I'm using the RowPrePaint event to add a custom row by drawing a string and a background. So far,so good.The problem comes when i use horizontal scrolling. Moving it to the right is not a problem, the...
8 Jan 2015 by Sergey Alexandrovich Kryukov
Combination of jQuery and HTML5 allows implementing themes purely on client side
23 Dec 2014 by hiroyukki
I encountered the same problem when I writing printer content monitor.I hooked StartDocW EndDoc StartPage EndPage and hook many GDI APIS (DrawTextExA, FillRect ...)when StartDocW occured.I tee gdi actions to emf file to get the printer content. It works ok usually, but as same as your...
22 Dec 2014 by Gerald Degeneve
Draw or render a Windows Form directly over the Wallpaper, behind the Desktop Icons in Windows 8+10
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...
29 Nov 2014 by DamithSL
try with TextRenderer.MeasureText Method[^] sample code : String text1 = "Measure this text"; Font arialBold = new Font("Arial", 12.0F); Size textSize = TextRenderer.MeasureText(text1, arialBold); TextRenderer.DrawText(e.Graphics, text1, arialBold, new...
29 Nov 2014 by Umut Comlekcioglu
Hi everyone,I'm developing new software for me. But I have a little problem. When I wanna get the String Width, already I use that code;float aa = pe.Graphics.MeasureString("PROGRAMMING", Font).Width;But this value is not correct. When I test that line with that...
25 Nov 2014 by Kunal Chowdhury «IN»
String interpolation in C# 6.0
24 Nov 2014 by Jeremy Falcon
A beginner's guide to talking like a computer.
20 Nov 2014 by Gregory Morse
How to use uniscribe from VB.NET
1 Nov 2014 by lowanda
cool and great all the fans. Pretty perfect then.