activex - save graphics to file
-
hi - i have an mfc activex control and want to save its visuals to a file. how should i do this? the graphics on the control are created through GDI+, so should i go through Graphics contents to an Image, or may be through CDC? thanx so far i have this: CDC* pdc = GetDC(); RECT rect; GetClientRect(&rect); Graphics graphics(pdc->GetSafeHdc()); Bitmap bitmap(rect.right - rect.left, rect.bottom - rect.top, &graphics); CLSID pngClsid; GetEncoderClsid(L"image/jpeg", &pngClsid); bitmap.Save(fineName, &pngClsid, NULL); but it just outputs a black screen, which is understandable
-
hi - i have an mfc activex control and want to save its visuals to a file. how should i do this? the graphics on the control are created through GDI+, so should i go through Graphics contents to an Image, or may be through CDC? thanx so far i have this: CDC* pdc = GetDC(); RECT rect; GetClientRect(&rect); Graphics graphics(pdc->GetSafeHdc()); Bitmap bitmap(rect.right - rect.left, rect.bottom - rect.top, &graphics); CLSID pngClsid; GetEncoderClsid(L"image/jpeg", &pngClsid); bitmap.Save(fineName, &pngClsid, NULL); but it just outputs a black screen, which is understandable
You should be able to use the WM_PRINT message to render the control into a DC of your own choice. With a bitmap of your own sleected into it of the correct size, you could then save the output to a file. If you vote me down, my score will only get lower
-
hi - i have an mfc activex control and want to save its visuals to a file. how should i do this? the graphics on the control are created through GDI+, so should i go through Graphics contents to an Image, or may be through CDC? thanx so far i have this: CDC* pdc = GetDC(); RECT rect; GetClientRect(&rect); Graphics graphics(pdc->GetSafeHdc()); Bitmap bitmap(rect.right - rect.left, rect.bottom - rect.top, &graphics); CLSID pngClsid; GetEncoderClsid(L"image/jpeg", &pngClsid); bitmap.Save(fineName, &pngClsid, NULL); but it just outputs a black screen, which is understandable
my search led me to GdipCreateBitmapFromGraphics method and this post: http://www.pscode.com/vb/scripts/ShowCode.asp?txtCodeId=37541&lngWId=1 where this guy - "Avery" - gives a great hint
-
You should be able to use the WM_PRINT message to render the control into a DC of your own choice. With a bitmap of your own sleected into it of the correct size, you could then save the output to a file. If you vote me down, my score will only get lower