Questions tagged [gdi]

Graphics Device Interface (GDI) is a device-independent, pure software graphics API under the Windows operating system for drawing graphic primitives and text. It is the underlying base used to render the Windows GUI elements.

Graphics Device Interface (GDI) is a device-independent, pure software graphics API under the Windows operating system for drawing graphic primitives and text. It is the underlying base used to render the Windows GUI elements.

More information at http://en.wikipedia.org/wiki/Graphics_Device_Interface

2158 questions
7
votes
3 answers

What bad things may happen without calling to ReleaseDC?

Programming with C++, once we get the context device by GetDC to use. What bad things may happen if we exit the program without calling to ReleaseDC?
jondinham
  • 8,271
  • 17
  • 80
  • 137
7
votes
2 answers

Drawing on a 16 bit greyscale bitmap in memory

In need to draw on a 16 bit greyscale in-memory bitmap. Associating a TCanvas to the bitmap would be marvelous. I use Delphi but any language is OK. I just need the idea. Any Idea ? Converting the greyscale to RGB is not an option because half the…
fpiette
  • 11,983
  • 1
  • 24
  • 46
7
votes
2 answers

Should we use OpenGL for 2D graphics?

If we want to make an application like MS Paint, should we use OpenGL for render graphics? I want to mention about performance if using traditional GDI vs. OpenGL. And if there are exist some better libs for this purpose, please see me one.
vietean
  • 2,975
  • 9
  • 40
  • 65
7
votes
2 answers

Given an HBITMAP, is there any way to find out, whether it contains an alpha channel?

In an attempt to improve this answer, I am looking for a way to determine, whether a bitmap referenced through an HBITMAP contains an alpha channel. I understand, that I can call GetObject, and retrieve a BITMAP structure: BITMAP bm = { 0…
IInspectable
  • 46,945
  • 8
  • 85
  • 181
7
votes
2 answers

How to get only the visible part of a window (Windows, gdi32, user32, etc)

I want to get only the visible part of the window in windows, as a region. Want to get only the area that is seen by the user. Programmatically, of course. Here is an example. I have the following window…
Nikola Yovchev
  • 9,498
  • 4
  • 46
  • 72
7
votes
4 answers

How can I measure diagonal distance points?

I can compute horizontal and vertical points, but I cant figure out how to compute distance using diagonal points. Can someone help me with this. here's the code for my horizontal and vertical measuring: private float ComputeDistance(float point1,…
Rye
  • 2,273
  • 9
  • 34
  • 43
7
votes
4 answers

Windows GDI: horizontal/vertical DPI

When obtaining the DPI for the screen under Windows (by using ::GetDeviceCaps) will the horizontal value always be the same as the vertical? For example: HDC dc = ::GetDC(NULL); const int xDPI = ::GetDeviceCaps(dc, LOGPIXELSX); const int yDPI -…
Rob
  • 76,700
  • 56
  • 158
  • 197
7
votes
1 answer

LinearGradientBrush does not render correctly

Consider the following code from a standard System.Windows.Forms.Form protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); Rectangle test = new Rectangle(50, 50, 100, 100); using (LinearGradientBrush brush = new…
Matthew Layton
  • 39,871
  • 52
  • 185
  • 313
7
votes
1 answer

Can I generate an anti-aliased font size larger than 149?

I have noticed, in Delphi XE6 (and in other tools/languages that produce applications that run on Windows, and use native GDI font rendering) that the Win32 TextOut API does not seem to smooth any font larger than 149, that is, the Font.Size>149.…
Warren P
  • 65,725
  • 40
  • 181
  • 316
7
votes
3 answers

Drawing text to a Bitmap with TextRenderer

I am trying to draw some text using TextRenderer (since this is favorable to using Graphics.DrawString) to a Bitmap, however it is having some very undesirable effects. Example Code using (Bitmap buffer = new Bitmap(this.ClientRectangle.Width,…
Matthew Layton
  • 39,871
  • 52
  • 185
  • 313
7
votes
2 answers

MonoMac System.Drawing.Image.GetPropertyItem(0x5100)

Recently, I was trying to answer another SO question about loading the frames (Bitmap and duration) of animated GIFs. The code can be found on pastenbin. While doing additional tests on this code before moving it into my dev library, I noticed that…
dsfgsho
  • 2,731
  • 2
  • 22
  • 39
7
votes
5 answers

GDI has been accelerated. Does anyone know when this happened?

To sketch the background of this question : at work we use Dell Precision workstations. My current one has got an NVidia Quadro FX1700. My team is developing the graphics components for a real time data acquisition system. So we are always looking…
QBziZ
  • 3,170
  • 23
  • 24
7
votes
1 answer

Redraw Window Control Synchronously (with blocking method)

What I am trying to do is to cause a control (in the same process, but which I have no control of) to redraw itself, and for my code to block until it finished redrawing. I tried using UpdateWindow but that doesn't seem to wait for the redraw to…
Rotem
  • 21,452
  • 6
  • 62
  • 109
7
votes
2 answers

Unable to Calculate Position within Owner-Draw Text

I'm trying to use Visual Studio 2012 to create a Windows Forms application that can place the caret at the current position within a owner-drawn string. However, I've been unable to find a way to accurately calculate that position. I've done this…
Jonathan Wood
  • 65,341
  • 71
  • 269
  • 466
7
votes
1 answer

Alpha channel in DeviceContext (HDC)

Please help me with alpha channel in HDC. I make HDC dc throw CreateCompatibleDC. Than call CreateDIBSection and can find bytes of image in memory. Than call DrawFrameControl to this dc. All works, but in memory there are 4 bytes per pixel and alpha…
QuitLN
  • 83
  • 5