gdi

Underline is drawn outside of rectangle reported by DrawText with DT_CALCRECT

别说谁变了你拦得住时间么 提交于 2019-12-10 20:44:20
问题 Symptoms I'm having an issue with the recent version 2.0 of the Lato font in its "Regular" variant. This issue doesn't appear with Lato 1.0. It seems that the underline is drawn 1px below the rectangle reported by DrawText() with the DT_CALCRECT flag. In the following screenshots the calculated rectangle is indicated by the blue background. I've added 10px to the right of this rectangle so you can see the discrepancy to the position where the underline is drawn. Lato 2.0 - underline is

How to display a TBitmap with alpha channel on TImage correctly?

别来无恙 提交于 2019-12-10 19:56:51
问题 I have a TBitmap which contains semi-transparent image with alpha channel (in this example I got it from TPngImage). var SourceBitmap: TBitmap; PngImage: TPngImage; begin PngImage := TPngImage.Create(); SourceBitmap := TBitmap.Create(); try PngImage.LoadFromFile('ImgSmallTransparent.png'); SourceBitmap.Assign(PngImage); SourceBitmap.SaveToFile('TestIn.bmp'); imgSource.Picture.Assign(SourceBitmap); finally PngImage.Free(); SourceBitmap.Free(); end; When I save this TBitmap to a TestIn.bmp file

Delphi EOutOfResources (GDIError)

我怕爱的太早我们不能终老 提交于 2019-12-10 18:43:17
问题 I have written an application in which I find ocasionally EOutofResources errors raised by GDIError method of Graphics unit when saving TBitmap32 to a stream. As far as I know it can come from gdi limits or heap limits. i know that for the process there is a default limit of 10000 handles. So my application according to the task manager reports only 620. I have downloaded and run Desktop Heap Information Monitor Tool which reported this: Desktop Heap Information Monitor Tool (Version 8.1.2925

Correct (and flicker-free) way of setting window pixels?

只谈情不闲聊 提交于 2019-12-10 18:05:36
问题 I'm struggling to figure out the proper way of dumping an array of plain RGBA values into the client area of a Win32 window during WM_PAINT. I have the following code but it already seems convoluted and I'm not even finished: case WM_ERASEBKGND: return 1; case WM_PAINT: { PAINTSTRUCT paintInfo{}; HDC device = BeginPaint(window, &paintInfo); if (device == nullptr) throw runtime_error(RG_LOCATION()); ScopeExit endPaint([&] { EndPaint(window, &paintInfo); }); HDC offscreenDevice =

Win32 GDI Drawing a circle?

允我心安 提交于 2019-12-10 16:07:53
问题 I am trying to draw a circle and I am currently using the Ellipse() function. I have the starting mouse coordinates - x1 and y1 and the ending coordinates x2 and y2. As you can see, I am forcing the y2(temp_shape.bottom) to be = y1+(x2-x1). This doesn't work as intended. I know the calculation is completely wrong but any ideas on what is right? Code Below. case WM_PAINT: { hdc = BeginPaint(hWnd, &ps); // TODO: Add any drawing code here... RECT rect; GetClientRect(hWnd, &rect); HDC backbuffDC

Copying a bitmap from another HBITMAP

隐身守侯 提交于 2019-12-10 14:21:58
问题 I'm trying to write a class to wrap bitmap functionality in my program. One useful feature would be to copy a bitmap from another bitmap handle. I'm a bit stuck: void operator=( MyBitmapType & bmp ) { HDC dcMem; HDC dcSource; if( m_hBitmap != bmp.Handle() ) { if( m_hBitmap ) this->DisposeOf(); // copy the bitmap header from the source bitmap GetObject( bmp.Handle(), sizeof(BITMAP), (LPVOID)&m_bmpHeader ); // Create a compatible bitmap dcMem = CreateCompatibleDC( NULL ); m_hBitmap =

How to speed up BitBlt to capture screen with aero?

我是研究僧i 提交于 2019-12-10 13:45:19
问题 I use following code to capture the screen with GDI functions: // Prologue: int iScreenWidth = GetSystemMetrics(SM_CXSCREEN); int iScreenHeight = GetSystemMetrics(SM_CYSCREEN); HDC hScreenDC = GetDC(0); HDC hCaptureDC = CreateCompatibleDC(hScreenDC); HBITMAP hCaptureBitmap = CreateCompatibleBitmap(hScreenDC, iScreenWidth, iScreenHeight); HBITMAP hOldBitmap = (HBITMAP)SelectObject(hCaptureDC, hCaptureBitmap); // Capture: BitBlt(hCaptureDC, 0, 0, iScreenWidth, iScreenHeight, hScreenDC, 0, 0,

Using FillRect() in C++

和自甴很熟 提交于 2019-12-10 13:18:49
问题 I am new to using Graphics in Visual C++. I am just trying to make a rectangle filled with a color. Need help to correct this... RECT rect; HDC hdc; hdc=CreateDC(TEXT("DISPLAY"),NULL,NULL,NULL); rect.left=30; rect.right=100; rect.top=50; rect.bottom=200; FillRect(hdc,&rect,(HBRUSH)(RGB(40,151,151))); The error is: ERROR: The variable 'rect' is being used without being initialized. 回答1: This will normally be a warning, not an error. In this case, it also appears to be spurious. It might work

How to draw text with transparent background using c++/WinAPI?

守給你的承諾、 提交于 2019-12-10 12:39:03
问题 How to draw text with transparent color using WinAPI? In usual way I used SetBkMode(hDC, TRANSPARENT), but now I need to use double buffer. In this way images draws correct, but text draws not correct (with black background). case WM_PAINT: { hDC = BeginPaint(hWnd, &paintStruct); SetBkMode(hDC, TRANSPARENT); HDC cDC = CreateCompatibleDC(hDC); HBITMAP hBmp = CreateCompatibleBitmap(hDC, width, height); HANDLE hOld = SelectObject(cDC, hBmp); HFONT hFont = (HFONT)SelectObject(hDC, font);

MemDC in OnPaint()-function

孤者浪人 提交于 2019-12-10 12:08:16
问题 My OnPaint() function calls several other drawing functions. void CGraph::OnPaint () { CPaintDC dc(this); // CMemDC DC(&dc); dc.SetViewportOrg (0, 400); dc.SetMapMode(MM_ISOTROPIC); dc.SetWindowExt(1000, 800); dc.SetViewportExt(1000, -800); ProcessData (); DrawCoordinateSystem (&dc); DrawGrid (&dc); DrawGraph (&dc); } Example of DrawCoordianteSystem: void CGraph::DrawCoordinateSystem (CDC* pDC) { CPen PenBlack (PS_SOLID, 1, RGB(0, 0, 0)); pDC->SelectObject (PenBlack); // Rectangle round the