FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Bug in ResizeImg()
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: Bug in ResizeImg()
Posted: Thu Oct 29, 2015 01:24 PM

Antonio,

how can we paint faster an alpha-channel image with resize?

EMG

Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Bug in ResizeImg()
Posted: Thu Oct 29, 2015 01:43 PM

Enrico,

I am afraid that we can't (maybe using GDI+?) as FWH function ABPaint() just calls Windows API function AlphaBlend()

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: Bug in ResizeImg()
Posted: Thu Oct 29, 2015 01:50 PM

Antonio,

I tried GDIPLUSIMAGERESIZE( hBmp, nWidth, nHeight ) but it GPFs. What am I doing wrong?

EMG

Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: Bug in ResizeImg()
Posted: Thu Oct 29, 2015 02:34 PM
Antonio,

Antonio Linares wrote:FWH function ABPaint() just calls Windows API function AlphaBlend()


It seems that AlphaBlend() can resize the image:

https://msdn.microsoft.com/it-it/library/windows/desktop/dd183351(v=vs.85).aspx

Can you add two parameters with nWidth and nHeight (or can send me the source code to experiment)?

EMG
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: Bug in ResizeImg()
Posted: Thu Oct 29, 2015 04:21 PM
Alternatively, I found that ResizeBmp() works very well and fast if SetStretchBltMode() is set to COLORONCOLOR:

Code (fw): Select all Collapse
SetStretchBltMode (hdcDest, COLORONCOLOR);


What do you think about it?

EMG
Posts: 1516
Joined: Thu May 27, 2010 02:06 PM
Re: Bug in ResizeImg()
Posted: Thu Oct 29, 2015 06:44 PM
If you go to call gdi + pictures, you redimensionaleas also from GDI + ...

Code (fw): Select all Collapse
STATIC FUNCTION DRAWIMG( cFile, hDC, nWidth, nHeight, lImg )

    LOCAL hImg := LoadresizedImage( cFile ,nWith, nHeight)

 //   LOCAL hImg2

   // IF lImg
    //    hImg2 = RESIZEIMG( hImg, nWidth, nHeight )
   // ELSE
    //    hImg2 = RESIZEBMP( hImg, nWidth, nHeight )
   // ENDIF

    ABPAINT( hDC, 0, 0, hImg, 255 )

   // DELETEOBJECT( hImg2 )
    DELETEOBJECT( hImg )

    RETURN NIL

function LoadresizedImage( cFile ,nWith, nHeight)
local hbitmap
local ogdi:=gdibmp():new(  cFile  )
      ogdi:resize(  nWith, nHeight )
      hbitmap := ogdi:GetGDIHbitmap() 
      ogdi:end()
return hbitmap


or

Code (fw): Select all Collapse
STATIC FUNCTION DRAWIMG( cFile, hDC, nWidth, nHeight, lImg )

    LOCAL hgdiImg := GdiPlusImageLoadCachedFile( cFile )
    LOCAL  gdinewhBmp := GdiPlusImageResize(hgdiImg , nWidth, nHeight ) 
    LOCAL  hImg2 := GdiPlusCreateHBitmapImage( gdinewhBmp )

    ABPAINT( hDC, 0, 0, hImg2, 255 )

    DELETEOBJECT( hImg2 )
     GdiPlusImageDispose( gdinewhBmp )
      gdinewhBmp = nil

    RETURN NIL
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Bug in ResizeImg()
Posted: Thu Oct 29, 2015 07:20 PM

Enrico,

I already sent you function ABPaint() source code by email

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: Bug in ResizeImg()
Posted: Thu Oct 29, 2015 07:33 PM
mastintin wrote:If you go to call gdi + pictures, you redimensionaleas also from GDI + ...


Thank you, but doing so the file must be reloaded. I would want to resize an already loaded hBmp. Is it possible?

EMG
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: Bug in ResizeImg()
Posted: Thu Oct 29, 2015 07:33 PM
Antonio,

Antonio Linares wrote:Enrico,

I already sent you function ABPaint() source code by email


Thank you. I'll study it.

EMG
Posts: 1516
Joined: Thu May 27, 2010 02:06 PM
Re: Bug in ResizeImg()
Posted: Thu Oct 29, 2015 08:53 PM
ok. From hbitmap
Code (fw): Select all Collapse
Function GdiResizeImage( hImg , nwidth, nHeight) 
local  hGdiBmp:= GdiPlusCreateImageFrom32hBitmap( hImg )
 LOCAL  gdinewhBmp := GdiPlusImageResize(hgdibmp, nWidth, nHeight ) 
 LOCAL  hImg2 := GdiPlusCreateHBitmapImage( gdinewhBmp )
    GdiPlusImageDispose( hGdiBmp )
   GdiPlusImageDispose( gdinewhBmp )
Return hImg2
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: Bug in ResizeImg()
Posted: Thu Oct 29, 2015 08:57 PM

Thank you. But I think that using AlphaBlend() features would be much more efficient. I'm implementing the required changes.

EMG

Continue the discussion