gdi

Static control with WS_EX_TRANSPARENT style not repainted

Hi all, I am trying to create a control that implements the per-pixel alpha blend while painting a 32-bit bitmap. I extended a CWnd and use static control in the resource editor. I managed to paint the alpha channel correctly but still the static control keep painting the gray background. I overwrote the OnEraseBkgnd to prevent the co...

GDI handles with icons . l

i have a winforms application. i have a user control with a lot of icons. the user can load this control on a form many times (in a tabbed layout). right now i am loading the icons each time the control is created (could be up to 50 times in teh app). is there any way to cache these icons in the application. if i did this, would tha...

C++/Win32: How to get the alpha channel from an HBITMAP?

I have an HBITMAP containing alpha channel data. I can successfully render this using the ::AlphaBlend GDI function. However, when I call the ::GetPixel GDI function, I never get back values with an alpha component. The documentation does say that it returns the RGB value of the pixel. Is there a way to retrieve the alpha channel valu...

How to Create a Gdiplus::Bitmap from an HBITMAP, retaining the alpha channel information?

When I create a new Gdiplus::Bitmap using the Bitmap::FromHBITMAP function, the resulting Bitmap is opaque - none of the partial transparency from the original HBITMAP is preserved. Is there a way to create a Gdiplus::Bitmap from an HBITMAP which brings across the alpha channel data? ...

Strange problem about conversion between GDI+ to GDI: Bitmap and HBitmap

I want to convert gdi+ Bitmap into gdi object HBitmap. I am using the following method: Bitmap* img = new Bitmap(XXX); // lots of codes... HBITMAP temp; Color color; img->GetHBITMAP(color, &temp); the img object is drawing on a dialog. when this part of method is called, strange thing happens! the img displaying in ...

how to set GDI HDC's drawable region?

I want to draw a HBITMAP onto HDC, I used StretchDIBits. It works fine. ::StretchDIBits. however, I only want a window to watch the drawing result, beside the window, I wish the stretchDIBits do not take any effect(It can not draw on other area), how can I do this? ...

setting the lineend styles for Canvas.LineTo

Is there any way to set the style for the lineends for the TCanvas.LineTo method? It seems to default to rounded ends, which looks very bad for several lines in a row of different colours when Pen.Width is set to a large value (e.g. 9). It looks like this (rounded ends): ********........****** **********........****** **********.........

GDI+ Dithering Problem

I have a C++ application that uses the Win32 API for Windows, and I'm having a problem with GDI+ dithering, when I don't know why it should be. I have a custom control (custom window). When I receive the WM_PAINT message, I draw some Polygons using FillPolygon on a Graphics device. This Graphics device was created using the HDC from Beg...

How to imitate shadow around the thumbnails by StretchDIBits?

I am now writing a image viewer, It is used for view thumbnails. As it is ugly, I decide to draw shadow round thumbnail. There is background color. I am using StretchDIBits to draw a shadow image at the location of thumbnail. However it is really annoying that it cover the background color... When the background is white, it looks perfe...

Can any one provide me a sample of using CreateHatchBrush

I want to draw a shadow around a thumbnail in my software. It seems CreateHatchBrush can help but I do not know how to use it, can anyone provide me a sample in C++? Many thanks! ...

Mixing OpenGL and GDI on Windows.

I'm trying to work out a way to mix OpenGL rendering and GDI in Windows. Previously I've been rendering my OpenGL contents into a framebuffer object, extracting it and then blitting it into the windows GDI graphics context and then drawing my GDI stuff over the top. This is really crippling the framerate. I'd like to do the opposite to ...

Guidelines for Using Brushes and Pens

How expensive is it to create gdi brushes and pens? Should I create them on an add needed basis and wrap them in a using so they are disposed quickly, or should I create a static class similar to System.Drawing.Brushes class? ...

StretchBlt fails when printing

I have a chart (in bitmap format) that I'm trying to render to a printer using StretchBlt. When drawing to the screen, StretchBlt works fine. When drawing to a CutePDF printer, it returns 0, sets the last error to ERROR_INVALID_HANDLE, and works anyway. When drawing to a PDF995 printer or a physical HP printer, it returns 0, sets the ...

C++, win32, gdi Printing: DrawEdge does not reach as far as DrawText?

I am trying to print (using a printer, on paper, not on a screen) lines and text, using the the function DrawEdge and DrawText (http://msdn.microsoft.com/en-us/library/ms534882.aspx and http://msdn.microsoft.com/en-us/library/ms533909.aspx). They work quite fine, however, when I try to reach the bottom of my paper (about 35 milimeter awa...

GDI Leak Problem

Hi all, I noticed using task manager that the following code has a GDI leak in it. The count of GDI object in the process executing this code increases by 1 each time it executes however I can't seem to find the problem. Any help would be appreciated. // create new DC based on current HDC hDC = CreateCompatibleDC(GetDC()); // sele...

Best way to create a timer on screen

Hey! I had this idea of creating a count down timer, like 01:02, on the screen (fullsize). One thing is that I really don't have a clue on how to start. I do know basic c/c++, win32 api and a bit of gdi. Anyone have any pointers on how to start this? My program would be like making the computer into a big stopwatch (but with added fe...

Double-Buffering VB6 with BitBlt help

Edit: I updated version 2. Now It's monochrome. I tried to fix it by making sure to call CreateCOmpatibleBitmap with the window's DC rather than the memdc (as written), but it is still wrong :( Below are 3 different simplified versions of functions I have written. Version 1 works perfectly (but has flicker, obviously), version 2 does...

Intersecting GraphicsPath objects

How can I intersect two (.NET) GraphicsPath objects? ...

WinAPI - how to draw dotted line?

I create HPEN using WinAPI GDI method: HPEN hPen = CreatePen(PS_DOT, 1, color); Then draw line using the methods MoveToEx and LineTo. In fact drawn line is dashed. 3 pixels empty, 3 pixels with color -- dashed line. Why PS_DOT style doesn't draw dotted line? How to draw dotten line using WinAPI? ...

Win32 BitBlt -- mirror image horizontally

So I've read that StretchBlt can mirror images horizontally and/or vertically by negating the nWidthSrc/Dest and nHeightSrc/Dest parameters. I'd like this functionality without the performance overhead of a StretchBlt. I tried the same technique with BitBlt but it didn't work. Is there any way to mirror an image with something as simple...