gdi

Blt() to create a layer effect. Not working. Am I using the wrong logical function or something?

I have one window that is drawn to by various objects to create a layered effect (think of a heads up display where one object draws a compass, the other draws the grid lines, another the altimeter reading etc). So, each object has a black memory bitmap that it draws to. When I call that objects Draw function, the memory bitmap is blitte...

Developing applications expected to run over RDP; any tips ?

Supposing I was developing a fairly graphically intensive application (C++ or C#, graphics API undecided) for which most of the usage will be by remote users over RDP (either terminal server sessions or remote access to a single-user machine). It's obvious that non-essential "eye-candy" effects and animations should be avoided. My ques...

How can I draw a patternBrush with transparent backround (GDI) ?

Hi, I can't draw a pattern with a transparent background. This is my snippet : bitmap.CreateBitmap(8, 8, 1, 1, &bits) brush.CreatePatternBrush(&bitmap) hbrush = pCgrCurrentDC->SelectObject(&brush); // set text color TextCol = pCgrCurrentDC->SetTextColor(CgrColourPalRGB); int oldBkgrdMode = pCgrCurrentDC->SetBkMode(TRANSPARENT); //dr...

A generic error occurred in GDI+.

[ExternalException (0x80004005): A generic error occurred in GDI+.] IpitchitImageHandler.Data.ImageRepository.AddNewTempImage(Stream image, String extension, Guid PageId, Guid ImageId, ImageTransformCollection toDoTransforms) +1967 IpitchitImageHandler.Data.ImageRepository.AddNewTempImage(Stream image, String extension, Guid PageId...

"Exclusive" DirectDraw palette isn't actually exclusive

We're maintaining an old video game that uses a full-screen 256-color graphics mode with DirectDraw. The problem is, some applications running in the background sometimes try to change the system palette while the game is running, which results in corrupted graphics. We can (sometimes) detect when this happens by processing the WM_PALE...

How do I use GDI to draw text around a circular path?

I need to draw text onto a window HDC along a circular path using C/C++, and I'm getting google-eyed from searching for several hours. Can someone point me to a good reference? ...

Merging JPGs with GDI in C#

My scenario: I have one color background image JPG. I have one black text on white background JPG. Both images are the same size (height and width) I want to overlay the image with black text and white background over the color background image, i.e. the white background becomes transparent to see the color background beneath it. Ho...

Is GDI+ just a layer on top of GDI, or something new?

When GDI+ came out, I remember all the brouhaha about how it was the "new, faster, better" way to display stuff in Windows. But everytime I looked at it, it seemed to me that it was really just a COM wrapper around GDI. Is that true? Or is GDI+ really an independent graphical library that simply shares some paradigms with GDI? Personal...

Generating PDF files from .NET by using standard .NET GDI printing classes

I'm looking for a way to generate PDF files using the standard PrintDocument and Graphics (GDI) classes in .NET. As far as I know, the only way to do that is by printing to a PDF printer. The problem is that a PDF printer driver always asks for a filename, but I need to control the filename from my code. Using a PDF library like PDFShar...

Why would StretchDIBits fail on turning image upside down when drawing to EMF file?

I'm attempting to draw an image using StretchDIBits with an Enhanced Meta File handle as the HDC to my OnDraw function using C++ and Visual Studio 2008. I load the .bmp source file using GDIplus and using GetHBITMAP. If I use the HDC returned by BeginPaint there are no problems. If I draw the bitmap upright, flipped horizontally, or fli...

how to Improve DrawDIB's quality?

I am coding in c++, gdi I use stretchDIBits to draw Images to dc. ::SetStretchBltMode(hDC, HALFTONE); ::StretchDIBits( hDC, des.left,des.top,des.right - des.left,des.bottom - des.top, 0, 0, img.getWidth(), img.getHeight(), (img.accessPixels()), (img.getInfo()), DIB_RGB_COLORS...

What scaling factor to use for mapping the Font size on a high resolution monitor?

We have a requirement where our application needs to support high resolution monitors. Currently, when the application comes up in High res monitor, the text that it displays is too small. We use Arial 12 point font by default. Now to make the text visible, I need to change the font size proportionally. I am finding it tough to come up...

Why does windows let you draw on the whole screen?

I've been playing a big with the DC obtained with CreateDC(L"DISPLAY",NULL,NULL,NULL) and I've been wondering why does windows let you draw on the whole screen that easily, cause I think you could do some pretty evil stuff with that like putting a TIMER at 1ms and drawing a black rectangle on the whole screen every time the timer ticks. ...

Printer Emulators, PDF Writers and so on.

I will soon be working on 'Print' and 'Print Preview' features of a product I am working on. I do not own a printer nor do I have any intention of buying one. I am looking for any free software which I can use to test my printing code. What are the best free options I can use to emulate a printer? I am using GDI+ on Windows but platfor...

Resizing Image Quality Reduction

Hi, I have written a simple PhotoEditor helper class to downscale and crop images uploaded to my website. Everything is working but I am seeing unsatisfactory quality when the image is saved to file. I have read up on the different settings you can tweak below is my setup for resizing, cropping is identical. public Image ResizeImag...

How to Convert a gdi+ Bitmap-like struct into an HDC?

How to Convert a Bitmap-like struct into an HDC? I am now writting image processing program in c++, gdi. If I got a HDC. I can draw whatever I like on the HDC in gdi by the following code. // HDC is handy. HDC dc; dc.DrawXXX // I can draw using gdi method. Graphics gr(dc); // now I can also draw on the dc using gdi+ method. My...

How Do I Validate a JPEG Image in C# / .Net is not corrupted.

I need to be able to validate if a JPEG image is valid and not corrupted. This is not the same as question 210650 which just asks wants to validate that it is, in fact, a JPEG image. Loading from Image with validation eg: var testJpg = Bitmap.FromStream(filename, useEmbeddedColorManagement, validateData); will not throw an except...

How do I create a bitmap with an alpha channel on the fly using GDI?

I am using layered windows and drawing a rounded rectangle on the screen. However, I'd like to smooth out the jagged edges. I think that I'll need alpha blending for this. Is there a way I can do this with GDI? ...

Calculating a formatted string's width & height in C#

Hi, I am trying to generate a PDF using XSL(XML-FO) to transform a generated XML from a database. Because of complex rules in terms of paging for this document, calculations are done in determining the page breaks when I generate the XML that will be consumed by the XSL. I have noticed that I've been getting inconsistent results with ...

Insert Space Between Pixels

I need to be able to draw a bitmap that is at a specific resolution (~40 DPI), on screen using GDI, and also be able to replicate spacing between each pixel. The space is a fraction of the pixel size, but it is noticeable to the eye. Is there anyway to setup the Graphics class or a Bitmap to have it insert "white space" between drawn p...