FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin para Harbour/xHarbour Rotar imagen Error solo en 64 bits
Posts: 133
Joined: Mon May 12, 2008 04:13 PM
Rotar imagen Error solo en 64 bits
Posted: Sun Apr 24, 2016 06:59 PM
Saludos.

Necesito rotar una imagen, con Gdiplus lo hace bien y con freeimage tambi茅n lo hace bien, pero en win64 bits en ambos casos da error

Ejemplo que funciona bien

Code (fw): Select all Collapse
// Testing

#include "FiveWin.ch"

function Main()
Local oImg
聽 聽Local nFlags 聽 := nOr( OFN_PATHMUSTEXIST , OFN_NOCHANGEDIR , ;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽OFN_ALLOWMULTISELECT , OFN_EXPLORER , ;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽OFN_LONGNAMES )
聽 聽Local cImg
聽 聽cImg := cGetFile( "Bitmap (*.bmp)| *.bmp|" + 聽 聽 聽 聽 ;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽"DIB 聽 (*.dib)| *.dib|" + 聽 聽 聽 聽 聽;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽"PCX 聽 (*.pcx)| *.pcx|" 聽+ 聽 聽 聽 聽 ;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽"JPEG 聽(*.jpg)| *.jpg|" + 聽 聽 聽 聽 聽;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽"GIF 聽 (*.gif)| *.gif|" 聽+ 聽 聽 聽 聽 ;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽"TARGA (*.tga)| *.tga|" + 聽 聽 聽 聽 聽;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽"RLE 聽 (*.rle)| *.rle|" + 聽 聽 聽 聽 聽;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽"All Files (*.*)| *.*" 聽 聽 聽 聽 聽 聽 ;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 ,"Seleciona una Imagen", 4,, .f., .t., nFlags )

聽 聽 聽 聽 聽 聽 //Forma 1
聽 聽 聽 聽 聽 聽 oImg:= GDIBmp():new( cImg ) 
聽 聽 聽 聽 聽 聽oImg:Rotate( 3 ) //Rota 270 grados
聽 聽 聽 聽 聽 聽oImg:Save( "Imagen1.bmp" ) //imagen ya rotada
聽 聽 聽 聽 聽 聽oImg:End()

聽 聽 聽 聽 聽 聽 //Forma 2
聽 聽 聽 聽 聽 聽Define Image oImg FileName cImg
聽 聽 聽 聽 聽 聽 聽 oImg:RotateImage( 270 ) //Rota 270 grados
聽 聽 聽 聽 聽 聽 聽 oImg:SaveImage( "Imagen2.bmp", 0, 0 )  //imagen ya rotada
聽 聽 聽 聽 聽 聽oImg:End()


return nil

//------------------------------------------------------------------------//

procedure appsys // XBase++ requirement
return



Hay que tener en cuenta que para freeimage modifique el image.prg agregando el metodo de rotaci贸n

METHOD RotateImage( nAngle )
.....
Code (fw): Select all Collapse
METHOD RotateImage( nAngle ) CLASS TImage
聽 聽local hDib := DibFromBitmap( ::hBitmap )
聽 聽local cTempFile := cTempFile( , "BMP" )
聽 聽local lSaved, hBmp
聽 聽local hOldBmp 聽:= ::hBitmap
聽 聽local hOldPal 聽:= ::hPalette

聽 聽DibWrite( cTempFile, hDib )

聽 聽GloBalFree( hDib )
聽 聽
聽 聽hBmp := FIROTATEIMG( cTempFile, nAngle )

聽 聽FErase( cTempFile )
聽 聽
聽 聽IF hBmp != 0
聽 聽 聽 if ! Empty( hOldBmp )
聽 聽 聽 聽 聽 PalBmpFree( hOldBmp, hOldPal )
聽 聽 聽 endif
聽 聽 聽 聽 聽 聽
聽 聽 聽 ::hBitmap := hBmp
聽 聽 聽 聽 
聽 聽 聽 PalBmpNew( ::hWnd, ::hBitmap, ::hPalette )
聽 聽 聽 聽 
聽 聽 聽 ::Refresh()
聽 聽ENDIF 聽 
return nil



Agregue la funcion

Code (fw): Select all Collapse
Function FIROTATEIMG( cSrcFile, nAngle )

聽 聽local nSrcFormat, hDib, hDib2, lOk
聽 聽local nFormat, hInfoH, hInfo, hBits, hWnd, hDC, hBmp := 0

聽 聽nSrcFormat = FIGETFILETYPE( cSrcFile, 0 )

聽 聽hDib = FILOAD( nSrcFormat, cSrcFile, 0 )

聽 聽IF hDib <> 0
聽 聽 聽 hDib2 = FIRotate( hDib, nAngle )
聽 聽 聽 聽 
聽 聽 聽 IF hDib2 <> 0
聽 聽 聽 聽 聽hInfoH 聽= FIGETINFOHEADER( hDib2 )
聽 聽 聽 聽 聽hInfo 聽 = FIGETINFO( hDib2 )
聽 聽 聽 聽 聽hBits 聽 = FIGETBITS( hDib2 )
聽 聽 聽 聽 聽hWnd 聽 聽= GETDESKTOPWINDOW()
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽
聽 聽 聽 聽 聽#ifdef __CLIPPER__
聽 聽 聽 聽 聽 聽 聽hDC = GETDC32( hWnd )
聽 聽 聽 聽 聽#else
聽 聽 聽 聽 聽 聽 聽hDC = GETDC( hWnd )
聽 聽 聽 聽 聽#endif
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽
聽 聽 聽 聽 聽hBmp = CreateDiBitmap( hDC, hInfoH, CBM_INIT, hBits, hInfo, DIB_RGB_COLORS )

聽 聽 聽 聽 聽 #ifdef __CLIPPER__
聽 聽聽 聽 聽 聽ReleaseDC32( hWnd, hDC )
聽 聽 聽 聽 #else
聽 聽 聽 聽 聽聽 聽ReleaseDC( hWnd, hDC )
聽 聽 聽 聽 聽 #endif
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽
聽 聽 聽 聽 聽FIUNLOAD( hDib2 )
聽 聽 聽 ENDIF 聽 
聽 聽 聽 聽 
聽 聽 聽 FIUNLOAD( hDib )
聽 聽ENDIF 聽 聽 聽 聽 聽 

return hBmp


y por ultimo

Code (fw): Select all Collapse
DLL32 FUNCTION FIRotate( hDib AS LONG, nAngle AS _DOUBLE ) AS LONG;
聽 聽 聽 PASCAL FROM If( IsExe64(), "FreeImage_Rotate", "_FreeImage_Rotate@16" ) ;
聽 聽 聽 LIB hLib



Toda esta informaci贸n est谩 en los foros

Actualmente trabajo con
Fivewin 15.09
Harbour 3.2.0
Visual Studio 2013
MariaDb/MySql


Gracias.
Fivewin 16.11
Harbour 3.2.0
Visual Studio 2015 community
MariaDb/MySql

Ing. MSc. Luis Duque
http://www.accasoft.net
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Re: Rotar imagen Error solo en 64 bits
Posted: Sun Apr 24, 2016 10:22 PM

Luis,

He a帽adido ese m茅todo a la Clase TImage para la pr贸xima versi贸n de FWH y he realizado unos cambios en la funci贸n FWCallDll() para que soporte el par谩metro DOUBLE correctamente.

Te he enviado las nuevas librerias por email

Gracias!

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 1789
Joined: Tue Oct 11, 2005 05:01 PM
Re: Rotar imagen Error solo en 64 bits
Posted: Mon Apr 25, 2016 03:10 AM

Antonio, una pregunta, actualmente tanto harbour como xharbour, las funciones loadlibrary y freelibrary trabajan con punteros en lugar de num茅ricos, no sera posible ir pensando en una fwLoadLibrary y fwFreeLibrary para no colicionar con las nativas de los compiladores.

Salu2

Carlos Vargas

Desde Managua, Nicaragua (CA)
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Re: Rotar imagen Error solo en 64 bits
Posted: Mon Apr 25, 2016 06:18 AM

Carlos,

Si, tienes raz贸n.

gracias

regards, saludos

Antonio Linares
www.fivetechsoft.com

Continue the discussion