Bug in ResizeImg()

Re: Bug in ResizeImg()

Postby Enrico Maria Giordano » Thu Oct 29, 2015 1:24 pm

Antonio,

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

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8725
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Bug in ResizeImg()

Postby Antonio Linares » Thu Oct 29, 2015 1: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
User avatar
Antonio Linares
Site Admin
 
Posts: 42203
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Bug in ResizeImg()

Postby Enrico Maria Giordano » Thu Oct 29, 2015 1:50 pm

Antonio,

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

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8725
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Bug in ResizeImg()

Postby Enrico Maria Giordano » Thu Oct 29, 2015 2: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
User avatar
Enrico Maria Giordano
 
Posts: 8725
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Bug in ResizeImg()

Postby Enrico Maria Giordano » Thu Oct 29, 2015 4:21 pm

Alternatively, I found that ResizeBmp() works very well and fast if SetStretchBltMode() is set to COLORONCOLOR:

Code: Select all  Expand view  RUN
SetStretchBltMode (hdcDest, COLORONCOLOR);


What do you think about it?

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8725
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Bug in ResizeImg()

Postby mastintin » Thu Oct 29, 2015 6:44 pm

If you go to call gdi + pictures, you redimensionaleas also from GDI + ...

Code: Select all  Expand view  RUN


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: Select all  Expand view  RUN


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
 

 
User avatar
mastintin
 
Posts: 1516
Joined: Thu May 27, 2010 2:06 pm

Re: Bug in ResizeImg()

Postby Antonio Linares » Thu Oct 29, 2015 7:20 pm

Enrico,

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

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42203
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Bug in ResizeImg()

Postby Enrico Maria Giordano » Thu Oct 29, 2015 7: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
User avatar
Enrico Maria Giordano
 
Posts: 8725
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Bug in ResizeImg()

Postby Enrico Maria Giordano » Thu Oct 29, 2015 7:33 pm

Antonio,

Antonio Linares wrote:Enrico,

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


Thank you. I'll study it.

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8725
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Bug in ResizeImg()

Postby mastintin » Thu Oct 29, 2015 8:53 pm

ok. From hbitmap
Code: Select all  Expand view  RUN

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

 
User avatar
mastintin
 
Posts: 1516
Joined: Thu May 27, 2010 2:06 pm

Re: Bug in ResizeImg()

Postby Enrico Maria Giordano » Thu Oct 29, 2015 8:57 pm

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

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8725
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Previous

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 43 guests