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