gdi

How to render CRichEditCtrl on CDC with transparent backgorund ? (MFC)

北慕城南 提交于 2019-12-11 05:01:53
问题 I need help with rendering CRichEditCtrl content with transparent background on graphical context which is displayed on screen and printed as well. Now I have following code, which is working good except transparency issues: CRichEditCtrl ctrl; // my CRichEditCtrl CDC *dc; // - my graphical context dc->SetBkMode(TRANSPARENT); dc->DPtoHIMETRIC(&targetSize); CRect cHiMetricRect( 0, 0, origSize.cx*factor,origSize.cy*factor); CRect cTwipsRect( 0, 0, (TWIPS_INCH * targetSize.cx + HIMETRIC_INCH / 2

WS_EX_COMPOSITED - high CPU

自闭症网瘾萝莉.ら 提交于 2019-12-11 04:36:42
问题 I am using WS_EX_COMPOSITED style in my application but its running the CPU to 100%, is there way to stop my application drawing for a while and to resume only when i need ? Some people are suggesting to use Sleep's but where exactly in WndProc do i put sleeps ? Thanks in advance. 回答1: Don't use Sleep . It is the solution to almost no problems. It's true that WS_EX_COMPOSITED can hog CPU but mostly on XP in my experience. There is a much less significant performance hit on Vista and up.

How much memory should be allocated for the DIB data received from HBITMAP using GetDIBits function?

会有一股神秘感。 提交于 2019-12-11 04:15:44
问题 How much memory should be allocated for the DIB data received from HBITMAP using GetDIBits function? The GetDIBits function is described in MSDN as follow: int GetDIBits( __in HDC hdc, __in HBITMAP hbmp, __in UINT uStartScan, __in UINT cScanLines, __out LPVOID lpvBits, __inout LPBITMAPINFO lpbi, __in UINT uUsage ); However, the buffer to receive data lpvBits must be allocated before calling GetDIBits, because GetDIBits doesn't allocate this automatically. The question is how much memory

Using SetDefaultDllDirectories breaks Font handling

夙愿已清 提交于 2019-12-11 03:25:08
问题 I recently got a problem in a program that used to work fine. I tracked it down to the following code: using System.Drawing; using System.Runtime.InteropServices; namespace Foo { static class CProgram { [DllImport("kernel32.dll", CallingConvention = CallingConvention.StdCall)] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool SetDefaultDllDirectories(int directoryFlags); public const int LOAD_LIBRARY_SEARCH_DEFAULT_DIRS = 0x000001000; private static void Main() {

C# get font from postscript name

社会主义新天地 提交于 2019-12-11 03:18:52
问题 I need to get the font (System.drawing.Font), with the given postscript name. For example, if I give the input as "CourierNewPSMT", the Courier font should be loaded. Similarly if "Arial-Black" is the input, the "Arial Black" font should be loaded. Any ideas?? Note : "Arial-Black" is the postscript name of "Arial Black" font. "CourierNewPSMT" is the postcript name of "Courier New" font. Thanks in advance. Regards, James 回答1: If you're on a Mac, you can look at the font in Font Book and go

GDI Leak Problem

六眼飞鱼酱① 提交于 2019-12-11 02:23:23
问题 I noticed using task manager that the following code has a GDI leak in it. The count of GDI object in the process executing this code increases by 1 each time it executes however I can't seem to find the problem. Any help would be appreciated. // create new DC based on current HDC hDC = CreateCompatibleDC(GetDC()); // select a bitmap into the new DC and keep the old one HGDIOBJ hOldObj = SelectObject (hDC,hBM); // do somthing here --> 100% no leak here SomeFunction (hDC); // select the old

CreateDIBSection failed

偶尔善良 提交于 2019-12-11 02:15:57
问题 BITMAPINFO bmi; memset(&bmi,0,sizeof(BITMAPINFO)); bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); bmi.bmiHeader.biWidth =m_pImg->GetWidth(); bmi.bmiHeader.biHeight =m_pImg->GetHeight(); bmi.bmiHeader.biPlanes = 1; //if( m_pImg->GetInfo()->biBitCount!=16) //{ // bmi.bmiHeader.biBitCount = m_pImg->GetInfo()->biBitCount; //} //else //{ //ASSERT((m_pImg->GetInfo())->bmiHeader->biBitCount == 24); bmi.bmiHeader.biBitCount=24; bmi.bmiHeader.biCompression = BI_RGB; if (bmi.bmiHeader.biSizeImage ==

How to automatically choose most suitable font for different language?

Deadly 提交于 2019-12-11 01:36:22
问题 I need to get the most suitable font for different language. So I could draw different language's text without using GDI text out API such as TextOut. Actually, the api TextOut does it. HFONT hFont = NULL; LOGFONT lg = {0}; lg.lfHeight = 14; lg.lfWeight = FW_NORMAL; wcscpy_s(lg.lfFaceName, LF_FACESIZE ,L"Arial"); hFont = CreateFontIndirect(&lg); SelectObject(hdc,hFont); TextOut(hdc, 0, 50, L"abc我爱", 5); Because the Arial font does not support Chinese, TextOut should not be able to draw the

Load cursor with certain resolution

时光怂恿深爱的人放手 提交于 2019-12-10 23:28:55
问题 I have two cursor resources. The first one [IDC_CURSOR1] contains three different image types: 32x32, 24 bpp 48x48, 24 bpp 64x64, 24 bpp The second one [IDC_CURSOR2] contains only one: 48x48, 24 bpp If I'm calling LoadCursor(hInst, IDC_CURSOR1) it always loads 32x32 version and I was unable to find the way to load 48x48 or 64x64 version. In second case it loads 48x48 icon (because there is no other version), but it scales it down to 32x32. How can I load a cursor with other than 32x32

Bitmap.Save “Object is currently in use elsewhere” Threading Issue

前提是你 提交于 2019-12-10 20:46:34
问题 I have some code like this: public void SaveImage(int Counter) { var task = Task.Factory.StartNew(() => { var image = FinalImage; if (image != null) { image.Save(FinalImageSaveLocation + "test" + Counter + ".bmp"); } }, TaskCreationOptions.PreferFairness); } I have a for loop creating x amount of images using similar code below: for(int i = 0; i < 100; i++) { Pencil.DrawImage(image, x, y); //Pencil is created at a initialisation stage SaveImage(i); //by Pencil = Graphics.FromImage(FinalImage)