Capture image of part of a control?

For questions and postings not covered by the other forums
ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Capture image of part of a control?

Postby ConvertFromOldNGs » Fri Aug 07, 2009 1:16 pm

by Anonymous >> Sun, 10 Feb 2008 7:09:01 GMT

I want to do some elaborate drawing off-screen, capture part of the image and draw it on-screen - basically a patch, without a full redraw on-screen. Unfortunately createPicture captures the whole image. As a workaround I can capture that large image, draw it on a second off-screen surface that is the right size, with scale settings so exactly the right area is shown, then capture the small image and draw that on-screen. This two-step process works, but not using createPictureIndirect (the recommended method) under thin-client.
So I'm looking for a simpler solution. I've tried using bitblt but not succeeded. I've tried placing a transparent control of the right size over the large off-screen surface, but while createPicture captures the parent's backColor it doesn't capture its drawing. Anyone got any ideas?

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: Capture image of part of a control?

Postby ConvertFromOldNGs » Fri Aug 07, 2009 1:16 pm

by BeeJay >> Sun, 10 Feb 2008 20:58:09 GMT

I needed to do something similar in the past and did this by having the control in question parented by another picture control. Then I adjusted the top and left of the control in question to the appropriate "negative" offsets and sized the parent picture control such that its client area contains the desired area of the control in question.

Once the desired area was "visible" in the parent picture control, I then used the parent picture control as the receiver of the createPictureIndirect method.

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: Capture image of part of a control?

Postby ConvertFromOldNGs » Fri Aug 07, 2009 1:16 pm

by Reinier Noom >> Mon, 11 Feb 2008 1:21:57 GMT

Hi there,

We have done something similar using bitblt and the dibapi (device independent bitmap). Something like

dc := call getDC(hwnd);
//GDI API Calls
compDC := call createCompatibleDC(dc);
hBmp := call createCompatibleBitmap(dc, height, width);
call selectObject(compDC, hBmp);
call bitBlt(compDC, 0, 0, height, width, dc, 0, 0, #CC0020);
//DIBAPI Calls
pal := call getSystemPalette(dc);
hdib := call bitmapToDIB(hBmp, pal);

Unfortunately here we needed the bmp as a binary, and did not have the length. So we reverted to writing this to disk (using dibapi call saveDIB(hdib, fileName);) and reading it back in. (there is bound to be a better way of doing that)
Not sure if this would solve the createPictureIndirect. We had issues where by we were drawing on a device context via GDI calls and we wanted to capture this to a binary. Jade createPicture only captures Jade drawing commands so we only captured the picture controls as it was (its back colour and border style. So we ended up doing it the above way.

It maybe of some use.

Thanks

Reinier


Return to “General Discussion”

Who is online

Users browsing this forum: No registered users and 15 guests