FW_DrawImage with negative coordinates

Post Reply
AntoninoP
Posts: 375
Joined: Tue Feb 10, 2015 9:48 am
Location: Albenga, Italy
Contact:

FW_DrawImage with negative coordinates

Post 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?
User avatar
Silvio.Falconi
Posts: 7184
Joined: Thu Oct 18, 2012 7:17 pm
Been thanked: 9 times

Re: FW_DrawImage with negative coordinates

Post by Silvio.Falconi »

do you tried with ximage or image ?
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
nageswaragunupudi
Posts: 10733
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Been thanked: 10 times
Contact:

Re: FW_DrawImage with negative coordinates

Post 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)
Regards

G. N. Rao.
Hyderabad, India
AntoninoP
Posts: 375
Joined: Tue Feb 10, 2015 9:48 am
Location: Albenga, Italy
Contact:

Re: FW_DrawImage with negative coordinates

Post 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.
User avatar
nageswaragunupudi
Posts: 10733
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Been thanked: 10 times
Contact:

Re: FW_DrawImage with negative coordinates

Post 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
 


Image

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.
Regards

G. N. Rao.
Hyderabad, India
AntoninoP
Posts: 375
Joined: Tue Feb 10, 2015 9:48 am
Location: Albenga, Italy
Contact:

Re: FW_DrawImage with negative coordinates

Post 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...
User avatar
nageswaragunupudi
Posts: 10733
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Been thanked: 10 times
Contact:

Re: FW_DrawImage with negative coordinates

Post 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 )
Regards

G. N. Rao.
Hyderabad, India
Post Reply