gdi

How to get an BITMAP struct from a RenderTargetBitmap in C++/CLI?

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-08 08:34:49
问题 I've got a WPF RenderTargetBitmap in C++/CLI and I want to be able to create a BITMAP structure from it to use with BitBlt. I've not worked with BITMAP or RenderTargetBitmap much before, so any thoughts would be great! 回答1: Turns out that it was a little more complicated than simply using CopyPixels. In the C++/CLI managed code, I do the following: virtual BOOL fillBitmap(CDC* dc, CBitmap* bmp) { WPFContainer^ page = getWPFContainer(); // Get a bitmap from the DVE page RenderTargetBitmap ^rtb

display red channel of image using GDI

我只是一个虾纸丫 提交于 2019-12-08 08:23:43
问题 I have 24 bit RGB image.I want to display only the red channel onto the display using GDI. Should i use palette for that? What is the strategy to be used? Please guide me appropriately. 回答1: The quickest way is to use BitBlt . Create another 24 bit bitmap of the same size as your RGB image. Fill it with pure red. Then use BitBlt with SRCAND . As described in the documentation this Combines the colors of the source and destination rectangles by using the Boolean AND operator. 来源: https:/

winapi/gdi: FillRect(COLOR_BTNFACE) fills with strange grid-like brush on Windows 7 and wine; solid black on Windows XP

ε祈祈猫儿з 提交于 2019-12-08 06:45:13
问题 I'm trying to fill an off-screen bitmap/device context on Windows with the standard COLOR_BTNFACE solid color with FillRect() . However, on wine, I get this from the program below. Windows 7 shows this and Windows XP shows... this. I'm lost as to what I'm doing wrong, but I'm sure whatever that weird pattern is isn't right, and I know that black isn't the button face color, as the window looks right without the custom paint. I tried all of the following; they show the same thing: FillRect(rdc

Is there a way to add my own button inside the edit common control?

时光毁灭记忆、已成空白 提交于 2019-12-08 06:44:59
问题 Say, if I have a default EDIT common control in my MFC-based dialog window: I'm looking for a way to add a small "X" (or delete) button inside of it (here's my Photoshop rendering of what I need): Is there a way to do it by modifying the default edit control? 回答1: Please consider using new class CMFCEditBrowseCtrl . It does have method CMFCEditBrowseCtrl::EnableBrowseButton() to do exactly what you need. 回答2: If I wanted more than one button, I would investigate alternatives: See the

General capturing with WM_PRINT and WM_PRINTCLIENT, supported on at least Windows 7

雨燕双飞 提交于 2019-12-08 06:09:31
问题 So far I got this partially working capturing function in C#: /// <summary> /// Captures a HWND, using a WM_PRINT windows message to draw into a memory DC. /// Pro: Does also work if the HWND is not positioned inside the visible screen. /// Con: Does only work if the target handle supports WM_PRINT and WM_PRINTCLIENT. /// TODO: Subclass the target handle and hack the WM_PRINT support for various systems, including Windows 7. /// Example for Windows 2000 see http://www.fengyuan.com/article

How to print DIB backbuffer on printer - GDI, MFC

此生再无相见时 提交于 2019-12-08 06:07:09
问题 I'm using MFC's doc/view architecture to implement printing. I use double buffering, I draw everything onto my backbuffer which is DIB bitmap. Than I use StretchBlt to copy that DIB onto printer DC. The strange thing is - print preview is working well! When I print on virtual PDF printer, it is working well! But when I print on actual printer (I'm testing on two different printers - same results) - it just prints "garbage". The "garbage" means sometimes it prints totally black page, sometimes

how to Improve DrawDIB's quality?

蹲街弑〆低调 提交于 2019-12-08 04:53:28
问题 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, SRCCOPY ); However It is slow. So I changed to use DrawDib function. ::SetStretchBltMode(hDC, HALFTONE); DrawDibDraw( hdd, hDC, des.left,des.top,des.right - des.left,des.bottom - des.top, (LPBITMAPINFOHEADER)(img

How can I debug misleading GDI OutOfMemory exceptions?

我怕爱的太早我们不能终老 提交于 2019-12-08 04:03:38
问题 I have a function which resizes a bitmap. It's such a "bread and butter" operation that I simply copied it from another project: private Bitmap ResizeBitmap(Bitmap orig) { Bitmap resized = new Bitmap(this.Xsize, this.Ysize, PixelFormat.Format16bppGrayScale); resized.SetResolution(orig.HorizontalResolution, orig.VerticalResolution); using (Graphics g = Graphics.FromImage(resized)) { g.DrawImage(orig, 0, 0, resized.Width, resized.Height); } return resized; } However, I kept getting OutOfMemory

How to get an BITMAP struct from a RenderTargetBitmap in C++/CLI?

为君一笑 提交于 2019-12-07 23:00:44
I've got a WPF RenderTargetBitmap in C++/CLI and I want to be able to create a BITMAP structure from it to use with BitBlt. I've not worked with BITMAP or RenderTargetBitmap much before, so any thoughts would be great! Turns out that it was a little more complicated than simply using CopyPixels. In the C++/CLI managed code, I do the following: virtual BOOL fillBitmap(CDC* dc, CBitmap* bmp) { WPFContainer^ page = getWPFContainer(); // Get a bitmap from the DVE page RenderTargetBitmap ^rtb = gcnew RenderTargetBitmap(page->ActualWidth, page->ActualHeight, 96, 96, PixelFormats::Default); rtb-

Highlight the Rectangular Area while Dragging it

两盒软妹~` 提交于 2019-12-07 16:59:10
问题 I am creating a image viewer sort of application. I am on Windows and using .Net In my app, I am trying to highlight a Particular area while dragging. I have created a Rectangle. Rectangle areaRect = new Rectangle(100,100, 300, 300); Point ptOld = new Point(0, 0); Pen rectPen = new Pen(Brushes.White, 3); protected override void OnPaint(PaintEventArgs e) { Graphics dcPaint = e.Graphics; dcPaint.DrawRectangle(rectPen, areaRect); } Now I am dragging this rectangular area along with my mouse