gdi

How to convert bitmap to grayscale by pixel intensity using GDI?

笑着哭i 提交于 2019-11-29 04:26:20
I'm looking for the simple solution of how to convert the 32-bit bitmap to grayscale using GDI (not GDI+). Is there a possibility e.g. by changing the bitmap's pallete or something ? Of course there is plenty of examples in Delphi like this one , but I'm looking for a WinAPI function which would do this without iteration through the lines. I haven't found any single GDI function doing this. The easiest way, as David mentioned in his comment, is to scan each line and compute the pixel colors. What you are looking for is probably the luminance formula. There are few variations of this formula

How to capture the screen with the “Tool Tips”?

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-29 02:53:31
I am using GDI to capture the screen, and I have noticed that the "Tool Tips" are not included in the screenshot. This is my basic code: HDC hdcDesk = GetDC(0); HDC hdcMem = CreateCompatibleDC(hdcDesk); HBITMAP hbmMem = CreateCompatibleBitmap(hdcDesk, 1920, 1080); SelectObject(hdcMem, hbmMem); StretchBlt(hdcMem, 0, 0, 1920, 1080, hdcDesk, 0, 0, 1920, 1080, SRCCOPY); // Now save the bitmap... Can this be fixed, or should I use another approach to capture the screen (other than GDI)? Edit: This is a screenshot that I took that does not display the Tool Tip. Update: added CAPTUREBLT as suggested

Printing on roll paper

吃可爱长大的小学妹 提交于 2019-11-29 02:28:29
问题 I am using C# with Winforms. I am trying to print bills on a paper roll. The width of the paper is 3in but the length of the paper is dynamic (its a roll paper). The length depends on how many items are there in the list. E.g. in a purchase if there are 100 items sold then it will be quite long roll while for a single item purchased it would be of small length. When I print the report, after the end job, printer eject the last page more than I need. It eject paper as long as A4 size. I want

Transparency to text in GDI

独自空忆成欢 提交于 2019-11-29 02:13:42
i have created a Bitmap using GDI+.I am drawing text on to that bitmap using GDI Drawtext.Using Drawtext i am unable to apply tranparency. Any help or code will be appreciated. If you want to draw text without a background fill, SetBkMode(hdc,TRANSPARENT) will tell GDI to leave the background when drawing text. To actually render the foreground color of the text with alpha... is going to be more complicated. GDI does not actually support alpha channels all that widely in its APIs. Outside of AlphaBlend actually all it does is preserve the channel. Its actually not valid to set the upper bits

c# radial gradient brush effect in GDI and winforms

让人想犯罪 __ 提交于 2019-11-29 01:26:09
I have created a c# windows application and written 75% of the code. The program allows the user to create a flow chart, and will shade the flow chart shapes according to their status. I wanted them to become 3d buttons such as from the website Webdesign.org Rather than create a PNG for each button, I wanted to create them in C# using brushes or other technique, such as: // Create solid brush. SolidBrush blueBrush = new SolidBrush(Color.Blue); // Create points that define polygon. PointF point1 = new PointF(50.0F, 50.0F); PointF point2 = new PointF(100.0F, 25.0F); PointF point3 = new PointF

how do I do print preview in win32 c++?

自闭症网瘾萝莉.ら 提交于 2019-11-28 23:51:01
I have a drawing function that just takes an HDC. But I need to show an EXACT scaled version of what will print. So currently, I use CreateCompatibleDC() with a printer HDC and CreateCompatibleBitmap() with the printer's HDC. I figure this way the DC will have the printer's exact width and height. And when I select fonts into this HDC, the text will be scaled exactly as the printer would. Unfortunately, I can't to a StretchBlt() to copy this HDC's pixels to the control's HDC since they're of different HDC types I guess. If I create the "memory canvas" from a window HDC with same w,h as the

What is the difference between GetClientRect and GetWindowRect in WinApi?

和自甴很熟 提交于 2019-11-28 22:25:08
问题 What of these should I use in InvalidateRect to refresh my window? And why? 回答1: The window rect includes the non-client area, i.e. the window borders, caption bar etc. The client rect does not. GetWindowRect returns a rect in screen coordinates whereas GetClientRect returns a rect in client coordinates. InvalidateRect receives a rect in client coordinates. If you want to invalidate your entire client area, then pass NULL to InvalidateRect . You could pass in the rect returned by

GDI handle leak using TGIFImage in a second thread

痞子三分冷 提交于 2019-11-28 20:37:50
I have a background thread which loads images (either from disk or a server), with the goal of eventually passing them to the main thread to draw. When this second thread is loading GIF images using the VCL's TGIFImage class , this program sometimes leaks several handles each time the following line executes in the thread: m_poBitmap32->Assign(poGIFImage); That is, the just-opened GIF image is being assigned to a bitmap owned by the thread. None of these are shared with any other threads, i.e. are entirely localised to the thread. It is timing-dependent, so doesn't occur every time the line is

Delphi GDI对象之脱屏位图(Offscreen Bitmaps)

杀马特。学长 韩版系。学妹 提交于 2019-11-28 20:30:49
脱屏位图( Offscreen Bitmaps) 脱屏位图,也叫内存位图,普遍用于 Windows程序设计中。它在内存中制作图像,然后利用Draw方法在屏幕上显示出来。当用户想更快的在屏幕上绘制图像时,脱屏位图有助于避免闪烁。脱屏位图也适合于复杂制图程序。用户可以将图像预存起来,需要时显示出来。脱屏位图用于动画,最流行的动画制作方法是Microsoft的DirectX SDK。 脱屏位图的原则是三个简单的步骤: 建立内存位图( Create a memory bitmap) 绘制内存位图( Draw on the memory bitmap) 拷贝内存位图于屏幕( Copy the memory bitmap to the screen) 创建内存位图( Creating a Memory Bitmap) 创建内存位图很容易。事实上,前面的讲解中已经创建过好几次了。每次创建 TBitmap对象时就是在创建内存位图,其中一些是将文件载入内存位图中,还有一些是创建内存位图,设置其大小,然后绘制内存位图,例如: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 procedure TForm1.btn1Click(Sender: TObject); var Bitmap: TBitmap; I, X, Y, W,

How can I render a square bitmap to an arbitrary four-sided polygon using GDI?

荒凉一梦 提交于 2019-11-28 19:36:05
I need to paint a square image, mapped or transformed to an unknown-at-compile-time four-sided polygon. How can I do this? Longer explanation The specific problem is rendering a map tile with a non-rectangular map projection. Suppose I have the following tile: and I know the four corner points need to be here: Given that, I would like to get the following output: The square tile may be: Rotated; and/or Be narrower at one end than at the other. I think the second item means this requires a non-affine transformation. Random extra notes Four-sided? It is plausible that to be completely correct,