Page 1 of 1

Antonio - FIMakeThumbNailen timage

Posted: Sat Nov 29, 2014 2:14 pm
by carlos vargas
Antonio, por favor recuerda reincluir en fwh 14.11 FIMakeThumbNail, ya que desde hace unos meses no esta incluido en el source de timage.prg

de wathsnew.txt
* New: function FIMakeThumbNail( cSrcFile, cDstFile, nPixel ) --> lOk thanks to
Carlos Vargas:

viewtopic.php?p=155418#p155418

Re: Antonio - FIMakeThumbNailen timage

Posted: Sat Nov 29, 2014 3:21 pm
by Antonio Linares
Carlos,

incluido, muchas gracias! :-)

Re: Antonio - FIMakeThumbNailen timage

Posted: Wed Dec 03, 2014 8:36 pm
by mastintin
Respecto a esto tengo una buena noticia ...para eso no necesitamos FreeImage , por lo menos en 32bits....

en gdiplus.cpp :

HB_FUNC( GDIPLUSIMAGECREATETHUMB )
{
Bitmap * newImage = ( Bitmap * ) hb_parnl( 1 );
int nWidth = hb_parni( 2 );
int nHeight = hb_parni( 3 );
Image * hThumb = newImage->GetThumbnailImage( nWidth , nHeight, NULL, NULL );
hb_retnl( ( HB_LONG ) hThumb );
}

en Tgdiplus.prg :

METHOD CreateThumbnail( nWidth, nHeight ) CLASS GDIBmp
local oThumb:= gdiBmp():new()
local hImage := GdiPlusImageCreateThumb( ::hbmp, nWidth, nHeight )
oThumb:hBmp := hImage
Return oThumb


Function GDIPlusSaveThumbnail( cImageIni, cImageEnd , nWhidth, nHeight )

local cExtIni := Upper(cFileExt( cImageIni ))
local oImage:= GDIBmp():New( cImageIni )
local oThumb
local nScan
if( nScan:= aScan( oImage:aExtIni, cExtIni )) == 0
Msginfo( " el archivo "+ cImageIni + " tiene un formato no soportado")
return .f.
endif

oThumb:= oImage:CreateThumbmail( nWhidth, nHeight )
oThumb:Save( cImageEnd )

oImage:Destroy()
oThumb:Destroy()

return nil

Re: Antonio - FIMakeThumbNailen timage

Posted: Thu Dec 04, 2014 6:21 am
by cnavarro
mastintin wrote:Respecto a esto tengo una buena noticia ...para eso no necesitamos FreeImage , por lo menos en 32bits....

en gdiplus.cpp :

HB_FUNC( GDIPLUSIMAGECREATETHUMB )
{
Bitmap * newImage = ( Bitmap * ) hb_parnl( 1 );
int nWidth = hb_parni( 2 );
int nHeight = hb_parni( 3 );
Image * hThumb = newImage->GetThumbnailImage( nWidth , nHeight, NULL, NULL );
hb_retnl( ( HB_LONG ) hThumb );
}

en Tgdiplus.prg :

METHOD CreateThumbnail( nWidth, nHeight ) CLASS GDIBmp
local oThumb:= gdiBmp():new()
local hImage := GdiPlusImageCreateThumb( ::hbmp, nWidth, nHeight )
oThumb:hBmp := hImage
Return oThumb


Function GDIPlusSaveThumbnail( cImageIni, cImageEnd , nWhidth, nHeight )

local cExtIni := Upper(cFileExt( cImageIni ))
local oImage:= GDIBmp():New( cImageIni )
local oThumb
local nScan
if( nScan:= aScan( oImage:aExtIni, cExtIni )) == 0
Msginfo( " el archivo "+ cImageIni + " tiene un formato no soportado")
return .f.
endif

oThumb:= oImage:CreateThumbmail( nWhidth, nHeight )
oThumb:Save( cImageEnd )

oImage:Destroy()
oThumb:Destroy()

return nil


Manuel, quizás esta funcion debería quedar algo asi, porque si no en un caso devuelve un valor lógico y por otro nil :D

Code: Select all | Expand


Function GDIPlusSaveThumbnail( cImageIni, cImageEnd , nWhidth, nHeight )
local lSw     := .T.
local cExtIni := Upper(cFileExt( cImageIni ))
local oImage:= GDIBmp():New( cImageIni )
local oThumb
local nScan
 if( nScan:= aScan( oImage:aExtIni, cExtIni )) == 0

    Msginfo( " el archivo "+ cImageIni + " tiene un formato no soportado")
    //return .f.
    lSw  := .F.
 else

 oThumb:= oImage:CreateThumbmail( nWhidth, nHeight )
 oThumb:Save( cImageEnd )
 oImage:Destroy()
 oThumb:Destroy()

 endif

return lSw

 

Re: Antonio - FIMakeThumbNailen timage

Posted: Thu Dec 04, 2014 7:45 am
by mastintin
Cristobal , tienes razón , ya lo he cambiado en mi código . Gracias por el apunte.

Re: Antonio - FIMakeThumbNailen timage

Posted: Thu Dec 04, 2014 7:52 am
by mastintin
Ahora falta conseguir que funcione la creacion de bitmaps gdi+ desde stream que abre muchas posibilidades ya que permitiría cargar Imagenes gdi+ desde una url y desde recursos y luego pasarlos a bmps gdi pero mi c++ no da para ello :( .Guardar imagenes png en recursos en vez bmps de 32bits y usarlos como si fueran bmps normales sin usar freeImage seria estupendo.

Re: Antonio - FIMakeThumbNailen timage

Posted: Thu Dec 04, 2014 8:51 am
by Antonio Linares
Manuel,

Si publicas el código actualizado lo voy actualizando en FWH :-)

C++ ? Tu puedes con eso y mucho más ;-)