gdi

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

徘徊边缘 提交于 2019-11-29 13:11:50
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: CDC *mdc=new CDC (); HGDIOBJ tmp = mdc->SelectObject(bm); Result: tmp is NULL, indicating failure. =================================================== Attempt 2: CreateDIBSection In constructor: HBITMAP hbm; BITMAPINFOHEADER bih; BITMAPINFO bi; HANDLE hb; CDC* myDc = new CDC ()

Draw on screen with GDI+ (or GDI) similar to Inspect

六眼飞鱼酱① 提交于 2019-11-29 12:50:02
I'm trying to draw on the screen (the whole screen, on top of every other window) using GDI+. I've passed NULL to GetDC to get a HDC to the screen, and then used that to create a Graphics object, and used DrawRectangle to draw rectangles on the screen. Everything works..except...the inside of the rectangle won't update. Like if I draw it over a command prompt, and move the command prompt, the inside of the rectangle remains black. I expect to see whats under the rectangle. Here's the code that's doing the drawing.. Pen BluePen(Color(255, 0, 255, 0), 2); Graphics graphics(screenDC); graphics

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

一曲冷凌霜 提交于 2019-11-29 10:18:29
问题 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 PDFSharp or DynamicPDF is not an option, because they all provide their own API for generating PDF files. I need this for an internal application, so dependencies are

Create 1bpp mask from image

点点圈 提交于 2019-11-29 08:54:17
How do you create a 1 bit per pixel mask from an image using GDI in C#? The image I am trying to create the mask from is held in a System.Drawing.Graphics object. I have seen examples that use Get/SetPixel in a loop, which are too slow. The method that interests me is one that uses only BitBlits, like this . I just can't get it to work in C#, any help is much appreciated. Try this: using System.Drawing; using System.Drawing.Imaging; using System.Runtime.InteropServices; ... public static Bitmap BitmapTo1Bpp(Bitmap img) { int w = img.Width; int h = img.Height; Bitmap bmp = new Bitmap(w, h,

Template matching from a screenshot of a window

耗尽温柔 提交于 2019-11-29 08:18:48
What I've done I have a small template image which is meant to be used to find coordinates of matching subimages within a larger screenshot image. The screenshot itself is captured into a memory DC with the help of BitBlt , then converted into a cv::Mat via GetDIBits , like so: HDC windowDc = GetWindowDC(hwndTarget); HDC memDc = CreateCompatibleDC(windowDc); // ... HBITMAP hbmp = CreateCompatibleBitmap(windowDc, width, height); SelectObject(memDc, hbmp); BITMAPINFOHEADER bi = { sizeof(BITMAPINFOHEADER), // biSize width, // biWidth -height, // biHeight 1, // biPlanes 32, // biBitCount BI_RGB, /

GDI Acceleration In Windows 7 / Drawing To Memory Bitmap

孤者浪人 提交于 2019-11-29 08:06:47
My GDI program runs fine on Windows XP but on Windows Vista and 7 it looks pretty terrible due to the lack of GDI hardware acceleration. I recall reading an article a few years back saying that Windows 7 added hardware acceleration to some GDI functions, including BitBlt() function. Supposedly, if you if you draw to a memory bitmap and then use BitBlt() to copy the image to your main window it runs about the same speed as XP. Is that true? If it is true, how do you do it? I'm terrible at programming and am having a bit of trouble. I created the below class to to try and get it working: class

Heisenbug: WinApi program crashes on some computers

南笙酒味 提交于 2019-11-29 06:45:16
Please help! I'm really at my wits' end. My program is a little personal notes manager (google for "cintanotes"). On some computers (and of course I own none of them) it crashes with an unhandled exception just after start. Nothing special about these computers could be said, except that they tend to have AMD CPUs. Environment: Windows XP, Visual C++ 2005/2008, raw WinApi. Here is what is certain about this "Heisenbug": 1) The crash happens only in the Release version. 2) The crash goes away as soon as I remove all GDI-related stuff. 3) BoundChecker has no complains. 4) Writing a log shows

Hunting down EOutOfResources

只谈情不闲聊 提交于 2019-11-29 06:32:29
Question: Is there an easy way to get a list of types of resources that leak in a running application? IOW by connecting to an application ? I know memproof can do it, but it slows down so much that the application won't even last a minute. Most taskmanager likes can show the number, but not the type. It is not a problem that the check itself is catastrophic (halts the app process), since I can check with a taskmgr if I'm getting close (or at least I hope) Any other insights on resource leak hunting (so not memory) is also welcomed. Background: I've an Delphi 7/2006/2009 app (compiles with all

A generic error occurred in GDI+

∥☆過路亽.° 提交于 2019-11-29 06:18:22
[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, Guid ImageId) +85 IpitchitWeb.Sell.Controls.UploadImagesSubstep.UploadImages(Object sender, EventArgs e) in F:\Documents and Settings\Vjeran\My Documents\Visual Studio 2008\Projects\Ipitchit\IpitchitWeb\Sell\Controls\UploadImagesSubstep.ascx.cs:88 System.Web.UI

Is it possible to detect GDI leaks from the Visual Studio debugger?

北城以北 提交于 2019-11-29 05:38:10
问题 Leaking GDI objects can be seen from the task manager or from Process Explorer. (Well you don't see the leaks, but you can see if object uasage count continually goes up.) There are also tools that allow to view GDI objects by type, such as GDIView[a], DeLeaker, DPUS or the GDIDebug (sourecode). [a] Note that I consider GDIView a great tool to get the job done of identifying and confirming the existance GDI leaks, but it doesn't really help you to find the leaking code in large applications.