Page 1 of 1

DC of the window

Posted: Fri Aug 12, 2022 2:39 pm
by Natter
Hi,

There are several .png files. I need to get the DC of each of these files and put it in a specific position on my application window. How can I do this ?

Re: DC of the window

Posted: Fri Aug 12, 2022 4:08 pm
by Antonio Linares
Dear Yuri,

A DC (device context) belongs to a window, not to a PNG file.

I guess that you have several PNG files and you want to paint them on a window, is this correct ?

Re: DC of the window

Posted: Fri Aug 12, 2022 4:14 pm
by Natter
Yes !

Re: DC of the window

Posted: Fri Aug 12, 2022 4:16 pm
by Antonio Linares
Is it an animation ? I mean, do you want to paint them one after another, or just paint them on different locations ?

Do you need them as controls or just to paint them from the ON PAINT of the window ?

Re: DC of the window

Posted: Fri Aug 12, 2022 4:32 pm
by Natter
just paint them on different locations

just to paint them from the ON PAINT of the window

Re: DC of the window

Posted: Fri Aug 12, 2022 4:34 pm
by Antonio Linares
oWnd:bPainted := { || oWnd:DrawImage( cPngFile, aRect )

Re: DC of the window

Posted: Sat Aug 13, 2022 8:21 am
by Natter
Method oWnd:DrawImage( cPngFile, aRect ) works. Is it possible to read from bitmap not all the picture, but only the required fragment ?

Re: DC of the window

Posted: Sat Aug 13, 2022 3:23 pm
by Antonio Linares
Dear Yuri,

> but only the required fragment ?

A rectangular portion of it ?

what required fragment ?

Re: DC of the window

Posted: Sat Aug 13, 2022 6:21 pm
by Natter
There is a picture file of 1920x1080. For example, I need a rectangular fragment {900,500,1000,600}

Re: DC of the window

Posted: Sat Aug 13, 2022 10:48 pm
by nageswaragunupudi
Natter wrote:There is a picture file of 1920x1080. For example, I need a rectangular fragment {900,500,1000,600}


Use this function:

Code: Select all | Expand

function FW_TransformBitmap( hBmp, [aCrop], [nZoom], [nRotate], [nBkClr] )


Example usage:

Code: Select all | Expand

hBmp := oWnd:ReadImage( cPngFile )[ 1 ]
hCropBmp := FW_TransformBitmap( hBmp, aCropRect )
DeleteObject( hBmp )
oWnd:DrawImage( hCropBmp, aRect )`
DeleteObject( hCropBmp )

Re: DC of the window

Posted: Sun Aug 14, 2022 10:24 am
by Natter
Yes, this is what we need.Thanks !