FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin para Harbour/xHarbour GIF animado
Posts: 446
Joined: Mon Dec 26, 2005 09:11 PM
GIF animado
Posted: Sat Sep 20, 2008 02: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
Posts: 2170
Joined: Fri Jul 18, 2008 01:24 AM
Re: GIF animado
Posted: Sat Sep 20, 2008 03: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.
Francisco J. Alegr铆a P.

Chinandega, Nicaragua.



Fwxh-MySql-TMySql
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
GIF animado
Posted: Sat Sep 20, 2008 09: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
Posts: 344
Joined: Tue Oct 11, 2005 11:33 AM
GIF animado
Posted: Sat Sep 20, 2008 02:13 PM
Antonio,

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

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++
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
GIF animado
Posted: Sat Sep 20, 2008 03: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
Posts: 446
Joined: Mon Dec 26, 2005 09:11 PM
GIF animado
Posted: Sat Sep 20, 2008 04: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
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
GIF animado
Posted: Sun Sep 21, 2008 08: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
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
GIF animado
Posted: Sun Sep 21, 2008 09: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:
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:
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:
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 ];
}

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
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
GIF animado
Posted: Sun Sep 21, 2008 09: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
#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
Posts: 189
Joined: Sun Jul 08, 2007 01:46 AM
GIF animado
Posted: Sun Sep 21, 2008 12:43 PM

Antonio:

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

Saludos

Ruben Fernandez

Posts: 446
Joined: Mon Dec 26, 2005 09:11 PM
GIF animado
Posted: 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

Continue the discussion