gdi

Invalidating non-client areas

I've a window which has custom border/caption, in order to do that I handle WM_NCPAINT message. My caption has two backgrounds a brighter one for the active window, and a darker one for the background window. But under some circumstances, for example when the window loses/gain focus, my caption is not updated so I end with the wrong ba...

GDI fast scroll

Hi! I use GDI to create some custom textwidget. I draw directly to the screen, unbuffered. now i'd like to implement some fast scrolling, that simply pixelshifts the respective part of the framebuffer (and only redraws the newly visible lines). I noticed that for example the rich text controls does it like this. If i use some GDI draw...

How to effectively draw on desktop in C#?

I want to draw directly on the desktop in C#. From searching a bit, I ended up using a Graphics object from the Desktop HDC (null). Then, I painted normally using this Graphics object. The problem is that my shapes get lost when any part of the screen is redrawn. I tried a While loop, but it actually ends up drawing as fast as the appli...

Strange error with CreateCompatibleDC

Maybe this is a foolish question, I can't see why I can not get a DC created in the following code : HBITMAP COcrDlg::LoadClippedBitmap(LPCTSTR pathName,UINT maxWidth,UINT maxHeight) { HBITMAP hBmp = (HBITMAP)::LoadImage(NULL, pathName, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE | LR_CREATEDIBSECTION); ...

Per-pixel per-component alpha blending in GDI

I have a 24-bit bitmaps with R, G, B color channels and a 24-bit bitmap with R, G, B alpha channels. I want to alpha blend the first bitmap to a HDC in GDI or RenderTarget in Direct2D with the alpha channels respectively. For example, suppose for one pixel, the bitmap color is (192, 192, 192), the HDC color is (0, 255, 255) and the alpha...

Stable random color algorithm

Here we have an interesting real-world algorithm requirement involving colors. 1) Nice random colors: In ordeeing to draw a beautifull chart (i.e: pie chart) we need to pick a random set of Colors that: a) are different enought b) Play nicely Doesnt Look hard. For example u fix bright and saturation and divide hue in steps of 360/N...

How to get the dimensions of an Icon from its handle?

I have a handle to the icon (HICON) and have to find out the dimensions of the icon that it represents. How do I get this information? ...

Windows fonts not immediately useable in application after installing?

Whenever I install a new font on a Windows 2003 server, I can't use it immediately in my asp.net web application. The application gets the font through the CreateFontIndirect gdi32.dll win api, and then use this font to create a dynamic text image in my asp.net application. It seems like fonts get cached somewhere, because I will just ge...

CreatePatternBrush and screen color depth

I am creating a brush using CreatePatternBrush with a bitmap created with CreateBitmap. The bitmap is 1 pixel wide and 24 pixels tall, I have the RGB value for each pixel, so I create an array of rgbquads and pass that to CreateBitmap. This works fine when the screen color depth is 32bpp, since the bitmap I create is also 32bpp. When ...

OpenGL equivalent of GDI's HatchBrush or PatternBrush?

I have a VB6 application (please don't laugh) which does a lot of drawing via BitBlt and the standard VB6 drawing functions. I am running up against performance issues (yes, I do the regular tricks like drawing to memory). So, I decided to investigate other ways of drawing, and have come upon OpenGL. I've been doing some experimenting...

Taking screenshots in Windows Vista, Windows 7, with transparent areas outside the app region

Hey Folks, I am trying to take a screenshot of an application and I would like to make the parts of the rectangle that are not part of the applications region be transparent. So for instance on a standard windows application I would like to make the rounded corners transparent. I wrote a quick test application which works on on XP (o...

VMRMixerControl9 & GDI problem!

I'm attempting to overlay a bitmap on some video. I create a bitmap in memory, then I call SelectObject to select it into a memoryDC, so I can perform a DrawText operation on it. I'm not getting any results on screen at all - can anyone suggest why? thanks HRESULT MyGraph::MixTextOverVMR9(LPCTSTR szText) { // create a bitmap object...

Is it reasonable to use OpenGL for desktop applications?

I've been writing a small desktop gadget-type application that displays scrolling text along the bottom of the screen (Similar to the old CNN news ticker), however the performance of GDI is just unsatisfactory (As high as 8-12% on a quad core and 20% on a single core) even after I've attempted to clean out bottlenecks. I was considering...

Altering an embedded TrueType font so it will be usable by Windows GDI

I am trying to render PDF content to a GDI device context (a 24bit bitmap to be exact). Parsing the PDF stream into PDF objects and rendering the PDF commands from the content dictionary works well, including font rendering. Embedded fonts are decompressed from their FontFile streams and "loaded" using AddFontMemResourceEx. Now some em...

Why doesn't FONTSIGNATURE reflect lfCharSet?

I'm enumerating Windows fonts like this: LOGFONTW lf = {0}; lf.lfCharSet = DEFAULT_CHARSET; lf.lfFaceName[0] = L'\0'; lf.lfPitchAndFamily = 0; ::EnumFontFamiliesEx(hdc, &lf, reinterpret_cast<FONTENUMPROCW>(FontEnumCallback), reinterpret_cast<LPARAM>(this), 0); My callback function has this sig...

A generic error occurred in GDI+ when Saving Images in ASP.NET

I get the exception "A generic error occurred in GDI+" when calling destImage.Save() at the end of this function. This resizes an image uploaded to my ASP.NET app: public static void ResizeImageFile(string sourceFileName, string destinationFileName, int width, int height) { using (var sourceImage = Image.FromFile(sourceFileNam...

How to explicitly release GDI handles allocated by TForm derived class owned by the Application?

Hi. A single class derived from TForm appears to hold onto GDI handles until the application is closed. class TTestForm : public TForm { public: TTestForm(TComponent*); }; std::auto_ptr<TTestForm> test(new TTestForm(NULL)); test->ShowModal(); I'm quite new to VCL, so please bear with me. This test was done with a form that con...

Drawing on 8bpp grayscale bitmap (unmanaged C++)

Hi all, I've been attempting to draw on an 8bpp grayscale bitmap without success. Here are some of my attempts. Maybe someone can point out what I'm doing wrong. =================================================== Attempt 1: Create, select, and draw: In constructor: CBitmap bm; bm.CreateBitmap (200, 200, 1, 8, NULL); In OnDraw: ...

Changing co-ordinate system

I need to switch from the XY co-ordinate system shown above to the X'Y' co-ordinate system using System::Drawing::Drawing2D (i.e. GDI+). This is what I have in mind: float rotation = // +90 below is because AB is the new vertical... Math::Atan2(pB.Y - pA.Y, pB.X - pA.X) * 180.0 / Math::PI + 90.0f; Matrix m; m.T...

How to find out DC's dimensions?

This might be rather trivial, however, after massive amounts of Googling, i haven't been able to find an answer. Let's say I have a handle to device context (naturally, in Windows environment): HDC hdc; How can I get the width and height of it? ...