FW_DrawImage with negative coordinates

FW_DrawImage with negative coordinates

Postby AntoninoP » Mon Apr 16, 2018 3:14 pm

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 view  RUN
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?
AntoninoP
 
Posts: 375
Joined: Tue Feb 10, 2015 9:48 am
Location: Albenga, Italy

Re: FW_DrawImage with negative coordinates

Postby Silvio.Falconi » Mon Apr 16, 2018 8:23 pm

do you tried with ximage or image ?
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 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
Silvio.Falconi
 
Posts: 7076
Joined: Thu Oct 18, 2012 7:17 pm

Re: FW_DrawImage with negative coordinates

Postby nageswaragunupudi » Tue Apr 17, 2018 3:43 am

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
User avatar
nageswaragunupudi
 
Posts: 10662
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: FW_DrawImage with negative coordinates

Postby AntoninoP » Tue Apr 17, 2018 7:35 am

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.
AntoninoP
 
Posts: 375
Joined: Tue Feb 10, 2015 9:48 am
Location: Albenga, Italy

Re: FW_DrawImage with negative coordinates

Postby nageswaragunupudi » Tue Apr 17, 2018 7:52 am

I understand you propose to make a new control for yourself.
You can use FW_DrawImage() with negative coordinates.

Code: Select all  Expand view  RUN
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
User avatar
nageswaragunupudi
 
Posts: 10662
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: FW_DrawImage with negative coordinates

Postby AntoninoP » Tue Apr 17, 2018 8:15 am

Interesting, If I change the calling in this way:
Code: Select all  Expand view  RUN
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 view  RUN
FW_DrawImage( Self, { ::hBitmap, ::hPalette, ::nImgWidth, ::nImgHeight }, aRect, ::lTransparent, 1, ::nAlphaLevel )


I will try with hDC...
AntoninoP
 
Posts: 375
Joined: Tue Feb 10, 2015 9:48 am
Location: Albenga, Italy

Re: FW_DrawImage with negative coordinates

Postby nageswaragunupudi » Tue Apr 17, 2018 9:09 am

AntoninoP wrote:Interesting, If I change the calling in this way:
Code: Select all  Expand view  RUN

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
User avatar
nageswaragunupudi
 
Posts: 10662
Joined: Sun Nov 19, 2006 5:22 am
Location: India


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 49 guests