Page 1 of 1
FW_DrawImage with negative coordinates
Posted: Mon Apr 16, 2018 3:14 pm
by AntoninoP
Hello,
I am trying to display 4 images inside a control, for this is necessary draw 3 of them starting from negative coordinates, but it does not work.
I am able to recreate the behavior with this code:
Code: Select all | Expand
proc main
LOCAL oWnd, oBr, oBmp
DEFINE WINDOW oWnd TITLE "Test BitMap"
@ 10,10 BITMAP oBmp SIZE 300,400 PIXEL OF oWnd ;
FILE "https://wikitravel.org/upload/en/thumb/3/32/Paris-eiffel-tower.jpg/300px-Paris-eiffel-tower.jpg"
oBmp:nX = -150
oBmp:nY = -200
oBmp:lStretch := .F.
ACTIVATE WINDOW oWnd
The expected result is the bottom right corner of the image drawn in the top left corner of control, but it does not happens...
Any suggest?
Re: FW_DrawImage with negative coordinates
Posted: Mon Apr 16, 2018 8:23 pm
by Silvio.Falconi
do you tried with ximage or image ?
Re: FW_DrawImage with negative coordinates
Posted: Tue Apr 17, 2018 3:43 am
by nageswaragunupudi
I think none of the 3 image controls, TBitmap, TImage or TXImage, support your requirement now. With TXImage, we can do it at runtime, either programetically or by the user, but we can not start with negative coordinates.
On seeing your requirement, we may provide it in the next version(s).
You say you want to display 4 images inside one control. None of the image controls of FWH support this. They can handle one image at a time.
The best solution is to make a collage of the 4 images and then view the resultant bitmap using one of the controls. You can use the new function FW_MakeYourBitmap(...) to make the collage. (version 18.03)
Re: FW_DrawImage with negative coordinates
Posted: Tue Apr 17, 2018 7:35 am
by AntoninoP
The problem are not the 4 images, the problem is FW_DrawImage with negative coordinate...
I was thinking to use the new methods FW_LoadImage and FW_DrawImage in my new control, TImage uses FreeImage, TXImage uses FW_DrawImage
The workaround I found is use FW_LoadImage and GDIBmp. Because I need to download from url and draw with negative coordinates.
Re: FW_DrawImage with negative coordinates
Posted: Tue Apr 17, 2018 7:52 am
by nageswaragunupudi
I understand you propose to make a new control for yourself.
You can use FW_DrawImage() with negative coordinates.
Code: Select all | Expand
function ImgTest()
local oDlg, oImage, aBmp
aBmp := FW_ReadImage( nil, "c:\fwh\bitmaps\olga1.jpg" )
DEFINE DIALOG oDlg SIZE 400, 500 PIXEL TRUEPIXEL
@ 20,20 BITMAP oImage SIZE 300,400 PIXEL OF oDlg
oImage:bPainted := { |hDC| FW_DrawImage( hDC, aBmp, { -200,-200,250,250 } ) }
ACTIVATE DIALOG oDlg CENTERED
PalBmpFree( aBmp )
return nil

You can use FW_DrawImage() in the paint method of your new control in the above manner.
Soon, we will provide initializing TXImage with negative coordinates.
Re: FW_DrawImage with negative coordinates
Posted: Tue Apr 17, 2018 8:15 am
by AntoninoP
Interesting, If I change the calling in this way:
Code: Select all | Expand
oImage:bPainted := { |hDC| FW_DrawImage( oImage, aBmp, { -200,-200,250,250 } ) }
The result is completely different...
That is how is called from FWH 18.01 TBitmap:
Code: Select all | Expand
FW_DrawImage( Self, { ::hBitmap, ::hPalette, ::nImgWidth, ::nImgHeight }, aRect, ::lTransparent, 1, ::nAlphaLevel )
I will try with hDC...
Re: FW_DrawImage with negative coordinates
Posted: Tue Apr 17, 2018 9:09 am
by nageswaragunupudi
AntoninoP wrote:Interesting, If I change the calling in this way:
Code: Select all | Expand
That is how is called from FWH 18.01 TBitmap:
[code=fw]FW_DrawImage( Self, { ::hBitmap, ::hPalette, ::nImgWidth, ::nImgHeight }, aRect, ::lTransparent, 1, ::nAlphaLevel )
Thank you very much.
Please change "Self" as "::hDC" in Bitmap.prg.
Now it works with setting :nX and :nY to negative values.
We are making this fix for 18.03. You can make this change and proceed as you originally planned.
Incidentally, we are now providing a new method in TXImage.
oImage:SetOrigin( nTop, nLeft )