Rotar imagen Error solo en 64 bits

Post Reply
luisduque
Posts: 133
Joined: Mon May 12, 2008 4:13 pm
Location: Venezuela
Contact:

Rotar imagen Error solo en 64 bits

Post by luisduque »

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


// 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


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



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


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
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: Rotar imagen Error solo en 64 bits

Post by Antonio Linares »

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
User avatar
carlos vargas
Posts: 1721
Joined: Tue Oct 11, 2005 5:01 pm
Location: Nicaragua

Re: Rotar imagen Error solo en 64 bits

Post by carlos vargas »

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)
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: Rotar imagen Error solo en 64 bits

Post by Antonio Linares »

Carlos,

Si, tienes razón.

gracias
regards, saludos

Antonio Linares
www.fivetechsoft.com
Post Reply