GIF animado

GIF animado

Postby Armando Picon » Sat Sep 20, 2008 2:26 am

Amigos

En un ejemplo que colocó Antonio indicaba que para hacer que funcionara un GIF animado se ejecutaba una función llamada CreateGIF(). Alguién tiene ese código para compartir?

Gracias por adelantado.

Armando
FWH + BCC582 + WorkShop 4.5 + Resource Hacker + Mingw
Mis nuevas herramientas
Comunicacion via WhatsApp (+51) 957549 665
Comunicación via Correo: apic1002002 at yahoo dot es; apic1002002@gmail.com
User avatar
Armando Picon
 
Posts: 446
Joined: Mon Dec 26, 2005 9:11 pm
Location: Lima, Peru

Re: GIF animado

Postby FranciscoA » Sat Sep 20, 2008 3:38 am

Armando Picon wrote:Amigos

En un ejemplo que colocó Antonio indicaba que para hacer que funcionara un GIF animado se ejecutaba una función llamada CreateGIF(). Alguién tiene ese código para compartir?

Gracias por adelantado.

Armando



Armando, ¿ya revisaste Win32.prg en samples?

Saludos.
FranciscoA.
User avatar
FranciscoA
 
Posts: 2110
Joined: Fri Jul 18, 2008 1:24 am
Location: Chinandega, Nicaragua, C.A.

Postby Antonio Linares » Sat Sep 20, 2008 9:12 am

Armando,

Este es el código que usamos como punto de partida:

https://xbmc.svn.sourceforge.net/svnroo ... tedGif.cpp
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41315
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Rossine » Sat Sep 20, 2008 2:13 pm

Antonio,

Ao compilar o exemplo \fwh\samples\testgif.prg me é gerado o erro abaixo:

Code: Select all  Expand view
xLINK: error: Unresolved external symbol '_HB_FUN_CREATEGIF'.
xLINK: error: Unresolved external symbol '_HB_FUN_GIFHWND'.
xLINK: fatal error: 2 unresolved external(s).


Qual arquivo devo incluir na compilação para corrgir estes erros ?

Obrigado,

Rossine.
Obrigado, Regards, Saludos

Rossine.

Harbour and Harbour++
Rossine
 
Posts: 344
Joined: Tue Oct 11, 2005 11:33 am

Postby Antonio Linares » Sat Sep 20, 2008 3:17 pm

Rossine,

The current code (C++) that we are using only compiles fine with Borland.

We have to modify it to get compiled with Microsoft and gcc. It fails with those compilers.

Our plan is to convert it into standard C code.
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41315
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Armando Picon » Sat Sep 20, 2008 4:27 pm

Antonio Linares wrote:Armando,

Este es el código que usamos como punto de partida:

https://xbmc.svn.sourceforge.net/svnroo ... tedGif.cpp


Bajé el codigo y lo estoy revisando... aunque una primera mirada no indica la presencia de CreateGIF(). De todas maneras se agradece...
FWH + BCC582 + WorkShop 4.5 + Resource Hacker + Mingw
Mis nuevas herramientas
Comunicacion via WhatsApp (+51) 957549 665
Comunicación via Correo: apic1002002 at yahoo dot es; apic1002002@gmail.com
User avatar
Armando Picon
 
Posts: 446
Joined: Mon Dec 26, 2005 9:11 pm
Location: Lima, Peru

Postby Antonio Linares » Sun Sep 21, 2008 8:32 am

Armando,

El problema es que ese código está en C++ y no es compatible con todos los compiladores de C++ ni con distintas versiones.

Lo mejor que podemos hacer es pasarlo de C++ a C y asi lo compatibilizamos para cualquier compilador C.

La forma de hacerlo es fácil, ya que un objeto en C++ no es sino un conjunto de datos que tiene unos comportamientos asociados, por lo que podemos pasar de Class a struct y manejar la estructura con una serie de funciones. Asi es como funcionan los RDDs de Clipper/[x]Harbour ó el sistema GT de gestión de pantalla.

En el siguiente mensaje pongo un ejemplo de como hacerlo. Finalmente añadiremos la función CreateGif(), etc.
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41315
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Antonio Linares » Sun Sep 21, 2008 9:17 am

En anigif.h se declaran tres classes: C_Image, C_ImageSet y C_AnimationWindow.

Pasemos la primera de C++ a C. Aqui está la definición de la clase:
Code: Select all  Expand view
class C_Image {
public:
   // standard members:
   int Width, Height;         // Dimensions in pixels
   int BPP;               // Bits Per Pixel   
   char * Raster;            // Bits of Raster Data (Byte Aligned)
   COLOR * Palette;         // Color Map
   int BytesPerRow;         // Width (in bytes) including alignment!
   int Transparent;         // Index of Transparent color (-1 for none)
   // Extra members for animations:
   int xPos, yPos;            // Relative Position
   int Delay;               // Delay after image in 1/1000 seconds.
   int Transparency;         // Animation Transparency.
   // Windows GDI specific:
   BITMAPINFO * pbmi;         // BITMAPINFO structure

   // constructor and destructor:
   C_Image() { Raster=0; Palette=0; pbmi=0; }
   ~C_Image() { delete[]pbmi; delete[]Raster; }

   // operator= (object copy)
   C_Image& operator= (C_Image& rhs);

   // Image initializer (allocates space for raster and palette):
   void Init (int iWidth, int iHeight, int iBPP);

   inline char& Pixel (const int& x, const int& y)
      {return Raster[y*BytesPerRow+x];}

   // Windows GDI Specific function to paint the image on a DC:
   int GDIPaint (HDC hdc, int xDest, int yDest);

   // File Formats:
   int LoadBMP (char* szFile);
   int SaveBMP (char* szFile);
};

Ahora la pasamos a una estructura:
Code: Select all  Expand view
typedef struct
{
   int Width, Height;         // Dimensions in pixels
   int BPP;               // Bits Per Pixel   
   char * Raster;            // Bits of Raster Data (Byte Aligned)
   COLOR * Palette;         // Color Map
   int BytesPerRow;         // Width (in bytes) including alignment!
   int Transparent;         // Index of Transparent color (-1 for none)
   // Extra members for animations:
   int xPos, yPos;            // Relative Position
   int Delay;               // Delay after image in 1/1000 seconds.
   int Transparency;         // Animation Transparency.
   // Windows GDI specific:
   BITMAPINFO * pbmi;         // BITMAPINFO structure
} CIMAGE, * PCIMAGE;

Y sus métodos los convertimos en funciones:
Code: Select all  Expand view
PCIMAGE CImageNew( void )
{
   PCIMAGE pCImage = ( PCIMAGE ) hb_xgrab( sizeof( CIMAGE ) );

   pCImage->Raster = 0;
   pCImage->Palette = 0;
   pCImage->pbmi    = 0;

   return pCImage;
}

Code: Select all  Expand view
void CImageDestroy( PCIMAGE pCImage )
{
   if( pCImage->pbmi )
   {
      hb_xfree( ( void * ) pCImage->pbmi );   
      pCImage->pbmi = 0;
   }

   if( pCImage->Raster )
   {
      hb_xfree( ( void * ) pCImage->Raster );   
      pCImage->Raster = 0;
   }
}

Code: Select all  Expand view
void CImageAssign( PCIMAGE pCImage, PCIMAGE pCAnotherImage )
{
   memcpy( ( void * ) pCImage, ( void * ) pCAnotherImage, sizeof( CIMAGE ) );
}

Code: Select all  Expand view
char CImagePixel( PCIMAGE pCImage, int x, int y )
{
   return PCImage->Raster[ y * pCImage->BytesPerRow + x ];
}

Estos son los métodos que estan definidos en la propia cabecera de la clase, ahora faltan los que estan en el fichero cpp.

Alguien se anima y asi practica su programación en C ? :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41315
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Antonio Linares » Sun Sep 21, 2008 9:36 am

Los juntamos en un fichero anigif.c y probamos a compilarlo con distintos compiladores de C y compilan bien todos :-)

c:\mingw\bin\gcc -c -Ic:\mingw\include -Ic:\harbour\include anigif.c

c:\bcc55\bin\bcc32 -c -Ic:\bcc55\include -Ic:\harbour\include anigif.c

c:\vc98\bin\cl.exe -c -Ic:\vc98\include -Ic:\harbour\harbour anigif.c

Es solo el comienzo. Alguien se anima ? Venga! :-)

anigif.c
Code: Select all  Expand view
#include <hbapi.h>
#include <windows.h>

typedef struct
{
   unsigned char b, g, r, x;
} COLOR;

typedef struct
{
   int Width, Height;       // Dimensions in pixels
   int BPP;                 // Bits Per Pixel   
   char * Raster;           // Bits of Raster Data (Byte Aligned)
   COLOR * Palette;         // Color Map
   int BytesPerRow;         // Width (in bytes) including alignment!
   int Transparent;         // Index of Transparent color (-1 for none)
   // Extra members for animations:
   int xPos, yPos;          // Relative Position
   int Delay;               // Delay after image in 1/1000 seconds.
   int Transparency;        // Animation Transparency.
   // Windows GDI specific:
   BITMAPINFO * pbmi;       // BITMAPINFO structure
} CIMAGE, * PCIMAGE;

PCIMAGE CImageNew( void )
{
   PCIMAGE pCImage = ( PCIMAGE ) hb_xgrab( sizeof( CIMAGE ) );

   pCImage->Raster = 0;
   pCImage->Palette = 0;
   pCImage->pbmi    = 0;

   return pCImage;
}

void CImageDestroy( PCIMAGE pCImage )
{
   if( pCImage->pbmi )
   {
      hb_xfree( ( void * ) pCImage->pbmi );   
      pCImage->pbmi = 0;
   }

   if( pCImage->Raster )
   {
      hb_xfree( ( void * ) pCImage->Raster );   
      pCImage->Raster = 0;
   }
}

void CImageAssign( PCIMAGE pCImage, PCIMAGE pCAnotherImage )
{
   memcpy( ( void * ) pCImage, ( void * ) pCAnotherImage, sizeof( CIMAGE ) );
}

char CImagePixel( PCIMAGE pCImage, int x, int y )
{
   return pCImage->Raster[ y * pCImage->BytesPerRow + x ];
}
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41315
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Ruben D. Fernandez » Sun Sep 21, 2008 12:43 pm

Antonio:

Solo para informacion:
Este código tambien compila bien con BS2006

Saludos

Ruben Fernandez
Ruben D. Fernandez
 
Posts: 189
Joined: Sun Jul 08, 2007 1:46 am
Location: Uruguay

Postby Armando Picon » Sun Sep 21, 2008 10:13 pm

Gracias Antonio...

Con el Codigo que indicaste estuve haciendo algunas pruebas para MinGW, sin éxito. Ahora con tu ejemplo voy a probar si puedo construirlo utilizando el Visual MinGW.

Gracias nuevamente

Armando
FWH + BCC582 + WorkShop 4.5 + Resource Hacker + Mingw
Mis nuevas herramientas
Comunicacion via WhatsApp (+51) 957549 665
Comunicación via Correo: apic1002002 at yahoo dot es; apic1002002@gmail.com
User avatar
Armando Picon
 
Posts: 446
Joined: Mon Dec 26, 2005 9:11 pm
Location: Lima, Peru


Return to FiveWin para Harbour/xHarbour

Who is online

Users browsing this forum: nageswaragunupudi and 96 guests