Antonio - FIMakeThumbNailen timage

Post Reply
User avatar
carlos vargas
Posts: 1721
Joined: Tue Oct 11, 2005 5:01 pm
Location: Nicaragua

Antonio - FIMakeThumbNailen timage

Post 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
Salu2
Carlos Vargas
Desde Managua, Nicaragua (CA)
User avatar
Antonio Linares
Site Admin
Posts: 42529
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Has thanked: 31 times
Been thanked: 77 times
Contact:

Re: Antonio - FIMakeThumbNailen timage

Post by Antonio Linares »

Carlos,

incluido, muchas gracias! :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
mastintin
Posts: 1516
Joined: Thu May 27, 2010 2:06 pm

Re: Antonio - FIMakeThumbNailen timage

Post 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
User avatar
cnavarro
Posts: 6557
Joined: Wed Feb 15, 2012 8:25 pm
Location: España
Been thanked: 3 times

Re: Antonio - FIMakeThumbNailen timage

Post 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

 
Cristobal Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
User avatar
mastintin
Posts: 1516
Joined: Thu May 27, 2010 2:06 pm

Re: Antonio - FIMakeThumbNailen timage

Post by mastintin »

Cristobal , tienes razón , ya lo he cambiado en mi código . Gracias por el apunte.
User avatar
mastintin
Posts: 1516
Joined: Thu May 27, 2010 2:06 pm

Re: Antonio - FIMakeThumbNailen timage

Post 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.
User avatar
Antonio Linares
Site Admin
Posts: 42529
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Has thanked: 31 times
Been thanked: 77 times
Contact:

Re: Antonio - FIMakeThumbNailen timage

Post by Antonio Linares »

Manuel,

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

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

Antonio Linares
www.fivetechsoft.com
Post Reply