EDN Admin
Well-known member
This is the code in visual studio c++ express 2010 i built this project and used the dll in my project on visual studio c# express 2010.
On my c# project sometimes when im creating the animated gif im getting the messagebox error.
So this is the code from the c++ before i compile it:
<div style="color:Black;background-color:White; <pre>
#include <span style="color:#A31515; "Stdafx.h"
<span style="color:Green; //#include <windows.h>
<span style="color:Green; //#include <commctrl.h>
<span style="color:Green; //#include <stdio.h>
<span style="color:Green; //#include "res_uf.h"
<span style="color:Blue; using <span style="color:Blue; namespace System::Collections::Generic;
<span style="color:Blue; using <span style="color:Blue; namespace System;
<span style="color:Blue; using <span style="color:Blue; namespace System::Windows::Forms;
<span style="color:Blue; #pragma pack(push,gifpacking,1)
typedef <span style="color:Blue; struct {
<span style="color:Blue; char cSignature[3]; <span style="color:Green; // Must be GIF
<span style="color:Blue; char cVersion[3]; <span style="color:Green; // Must be 89a
} GIF_HEADER;
typedef <span style="color:Blue; struct { <span style="color:Green; // 7 bytes
unsigned <span style="color:Blue; short iWidth;
unsigned <span style="color:Blue; short iHeight;
unsigned <span style="color:Blue; char iSizeOfGct : 3;
unsigned <span style="color:Blue; char iSortFlag : 1;
unsigned <span style="color:Blue; char iColorResolution : 3;
unsigned <span style="color:Blue; char iGctFlag : 1;
unsigned <span style="color:Blue; char iBackgroundColorIndex;
unsigned <span style="color:Blue; char iPixelAspectRatio;
} GIF_LOGICAL_SCREEN_DESCRIPTOR;
typedef <span style="color:Blue; struct { <span style="color:Green; // 6 bytes
unsigned <span style="color:Blue; char iBlockSize; <span style="color:Green; // Must be 4
unsigned <span style="color:Blue; char iTransparentColorFlag : 1;
unsigned <span style="color:Blue; char iUserInputFlag : 1;
unsigned <span style="color:Blue; char iDisposalMethod : 3;
unsigned <span style="color:Blue; char iReserved : 3;
unsigned <span style="color:Blue; short iDelayTime;
unsigned <span style="color:Blue; char iTransparentColorIndex;
unsigned <span style="color:Blue; char iBlockTerminator; <span style="color:Green; // Must be 0
} GIF_GRAPHIC_CONTROL_EXTENSION;
typedef <span style="color:Blue; struct { <span style="color:Green; // 9 bytes
unsigned <span style="color:Blue; short iLeft;
unsigned <span style="color:Blue; short iTop;
unsigned <span style="color:Blue; short iWidth;
unsigned <span style="color:Blue; short iHeight;
unsigned <span style="color:Blue; char iSizeOfLct : 3;
unsigned <span style="color:Blue; char iReserved : 2;
unsigned <span style="color:Blue; char iSortFlag : 1;
unsigned <span style="color:Blue; char iInterlaceFlag : 1;
unsigned <span style="color:Blue; char iLctFlag : 1;
} GIF_IMAGE_DESCRIPTOR;
<span style="color:Blue; #pragma pack(pop,gifpacking)
unsigned <span style="color:Blue; short iGctSize[]={6,12,24,48,96,192,384,768};
<span style="color:Green; //void UpdateFrameInfo(void);
<span style="color:Blue; void __MakeGIF( List<String^> ^file_list , String ^out_file , <span style="color:Blue; int delay , <span style="color:Blue; bool loop );
<span style="color:Green; //HINSTANCE hInst;
<span style="color:Green; //HANDLE hHeap;
<span style="color:Green; /*
void UpdateFrameInfo()
{
DWORD dwIndex, dw;
char sz[256], c;
char *pszFileName;
HANDLE hFile;
GIF_HEADER gh;
GIF_LOGICAL_SCREEN_DESCRIPTOR glsd;
GIF_IMAGE_DESCRIPTOR gid;
ZeroMemory(&gh,sizeof(GIF_HEADER));
ZeroMemory(&glsd,sizeof(GIF_LOGICAL_SCREEN_DESCRIPTOR));
ZeroMemory(&gid,sizeof(GIF_IMAGE_DESCRIPTOR));
dwIndex=SendDlgItemMessage(hMainDlg,IDC_LIST_MAIN_FRAMES,LB_GETCURSEL,0,0);
SendDlgItemMessage(hMainDlg,IDC_LIST_MAIN_FRAMES,LB_GETTEXT,dwIndex,(LPARAM)sz);
pszFileName=(char *)SendDlgItemMessage(hMainDlg,IDC_LIST_MAIN_FRAMES,LB_GETITEMDATA,dwIndex,0);
SetDlgItemText(hMainDlg,IDC_STATIC_MAIN_FILENAME,sz);
hFile=CreateFile(pszFileName,GENERIC_READ,FILE_SHARE_READ,0,OPEN_EXISTING,FILE_FLAG_SEQUENTIAL_SCAN,0);
if (hFile==INVALID_HANDLE_VALUE) {
MessageBox(hMainDlg,"Could not open file.",0,MB_ICONEXCLAMATION);
return;
}
ReadFile(hFile,&gh,sizeof(GIF_HEADER),&dw,0);
if (strncmp(gh.cSignature,"GIF",3) || (strncmp(gh.cVersion,"89a",3) && strncmp(gh.cVersion,"87a",3))) {
MessageBox(hMainDlg,"Not a GIF file, or incorrect version number.",0,MB_ICONEXCLAMATION);
CloseHandle(hFile);
return;
}
ReadFile(hFile,&glsd,sizeof(GIF_LOGICAL_SCREEN_DESCRIPTOR),&dw,0);
if (glsd.iGctFlag) SetFilePointer(hFile,iGctSize[glsd.iSizeOfGct],0,FILE_CURRENT);
for (; {
ReadFile(hFile,&c,1,&dw,0);
if (dw==0) {
MessageBox(hMainDlg,"Premature end of file encountered; no GIF image data present.",0,MB_ICONEXCLAMATION);
CloseHandle(hFile);
return;
}
if (c==0x2C) {
ReadFile(hFile,&gid,sizeof(GIF_IMAGE_DESCRIPTOR),&dw,0);
break;
} else if (c==0x21) {
ReadFile(hFile,&c,1,&dw,0);
if (c==0xF9) {
SetFilePointer(hFile,sizeof(GIF_GRAPHIC_CONTROL_EXTENSION),0,FILE_CURRENT);
} else {
for (; {
ReadFile(hFile,&c,1,&dw,0);
if (!c) break;
SetFilePointer(hFile,c,0,FILE_CURRENT);
}
}
}
}
CloseHandle(hFile);
sprintf(sz,"%d x %dn%s (%d bpp)",glsd.iWidth,glsd.iHeight,gid.iLctFlag?"local"glsd.iGctFlag?"global":"none"),gid.iLctFlag?(gid.iSizeOfLct+1)glsd.iSizeOfGct+1));
SetDlgItemText(hMainDlg,IDC_STATIC_MAIN_INFO,sz);
}
*/
<span style="color:Blue; void __MakeGIF( List<String^> ^file_list , String ^out_file , <span style="color:Blue; int my_delay , <span style="color:Blue; bool is_loop )
{
DWORD dwIndex, dw;
<span style="color:Blue; char szColorTable[768];
unsigned <span style="color:Blue; char c;
HANDLE hFileOut, hFileIn;
GIF_HEADER gh;
GIF_LOGICAL_SCREEN_DESCRIPTOR glsd1, glsd;
GIF_GRAPHIC_CONTROL_EXTENSION ggce;
GIF_IMAGE_DESCRIPTOR gid;
ZeroMemory(&glsd1,<span style="color:Blue; sizeof(GIF_LOGICAL_SCREEN_DESCRIPTOR));
<span style="color:Green; // new vars
DWORD total_files=file_list->Count;
<span style="color:Blue; char szFileName[MAX_PATH];
<span style="color:Blue; int i;
List<String^> ^fl = file_list;
<span style="color:Blue; for (i=0;i<out_file->Length;i++)
szFileName = (<span style="color:Blue; char)out_file;
szFileName = 0;
<span style="color:Blue; char current_file_name[MAX_PATH];
<span style="color:Blue; if (1)
{
hFileOut=CreateFile(szFileName,GENERIC_WRITE,FILE_SHARE_READ,0,CREATE_ALWAYS,0,0);
<span style="color:Green; //strncpy_s((char *)&gh,6,"GIF89a",6);
((<span style="color:Blue; char *)&gh)[0] = <span style="color:#A31515; G;
((<span style="color:Blue; char *)&gh)[1] = <span style="color:#A31515; I;
((<span style="color:Blue; char *)&gh)[2] = <span style="color:#A31515; F;
((<span style="color:Blue; char *)&gh)[3] = <span style="color:#A31515; 8;
((<span style="color:Blue; char *)&gh)[4] = <span style="color:#A31515; 9;
((<span style="color:Blue; char *)&gh)[5] = <span style="color:#A31515; a;
WriteFile(hFileOut,&gh,<span style="color:Blue; sizeof(GIF_HEADER),&dw,0);
WriteFile(hFileOut,&glsd1,<span style="color:Blue; sizeof(GIF_LOGICAL_SCREEN_DESCRIPTOR),&dw,0);
<span style="color:Blue; if (is_loop==<span style="color:Blue; true)
{
WriteFile(hFileOut,<span style="color:#A31515; "41377 13NETSCAPE2.001377377 ",19,&dw,0);
}
<span style="color:Blue; for (dwIndex=0;dwIndex<total_files;dwIndex++)
{
ZeroMemory(&glsd,<span style="color:Blue; sizeof(GIF_LOGICAL_SCREEN_DESCRIPTOR));
ZeroMemory(&ggce,<span style="color:Blue; sizeof(GIF_GRAPHIC_CONTROL_EXTENSION));
ZeroMemory(&gid,<span style="color:Blue; sizeof(GIF_IMAGE_DESCRIPTOR));
<span style="color:Blue; for (i=0;i<fl[dwIndex]->Length;i++)
current_file_name = (<span style="color:Blue; char)fl[dwIndex];
current_file_name=0;
hFileIn=CreateFile(current_file_name,GENERIC_READ,FILE_SHARE_READ,0,OPEN_EXISTING,FILE_FLAG_SEQUENTIAL_SCAN,0);
<span style="color:Blue; if (hFileIn==INVALID_HANDLE_VALUE) {
DWORD err = GetLastError();
MessageBox::Show(<span style="color:#A31515; "Could not open file. GIF creation aborted. : " + Convert::ToString((unsigned <span style="color:Blue; int)err) );
CloseHandle(hFileOut);
<span style="color:Blue; return;
}
ReadFile(hFileIn,&gh,<span style="color:Blue; sizeof(GIF_HEADER),&dw,0);
<span style="color:Blue; if (strncmp(gh.cSignature,<span style="color:#A31515; "GIF",3) || (strncmp(gh.cVersion,<span style="color:#A31515; "89a",3) && strncmp(gh.cVersion,<span style="color:#A31515; "87a",3))) {
MessageBox::Show(<span style="color:#A31515; "Not a GIF file, or incorrect version number.");
CloseHandle(hFileIn);
CloseHandle(hFileOut);
<span style="color:Blue; return;
}
ReadFile(hFileIn,&glsd,<span style="color:Blue; sizeof(GIF_LOGICAL_SCREEN_DESCRIPTOR),&dw,0);
<span style="color:Blue; if (glsd.iGctFlag) ReadFile(hFileIn,szColorTable,iGctSize[glsd.iSizeOfGct],&dw,0);
<span style="color:Blue; if (glsd1.iWidth<glsd.iWidth) glsd1.iWidth=glsd.iWidth;
<span style="color:Blue; if (glsd1.iHeight<glsd.iHeight) glsd1.iHeight=glsd.iHeight;
<span style="color:Blue; for (; {
ReadFile(hFileIn,&c,1,&dw,0);
<span style="color:Blue; if (dw==0) {
MessageBox::Show(<span style="color:#A31515; "Premature end of file encountered; no GIF image data present.");
CloseHandle(hFileIn);
CloseHandle(hFileOut);
<span style="color:Blue; return;
}
<span style="color:Blue; if (c==0x2C) {
ReadFile(hFileIn,&gid,<span style="color:Blue; sizeof(GIF_IMAGE_DESCRIPTOR),&dw,0);
<span style="color:Blue; if (gid.iLctFlag) {
ReadFile(hFileIn,szColorTable,iGctSize[gid.iSizeOfLct],&dw,0);
} <span style="color:Blue; else {
gid.iLctFlag=1;
gid.iSizeOfLct=glsd.iSizeOfGct;
}
<span style="color:Blue; break;
} <span style="color:Blue; else <span style="color:Blue; if (c==0x21) {
ReadFile(hFileIn,&c,1,&dw,0);
<span style="color:Blue; if (c==0xF9) {
ReadFile(hFileIn,&ggce,<span style="color:Blue; sizeof(GIF_GRAPHIC_CONTROL_EXTENSION),&dw,0);
} <span style="color:Blue; else {
<span style="color:Blue; for (; {
ReadFile(hFileIn,&c,1,&dw,0);
<span style="color:Blue; if (!c) <span style="color:Blue; break;
SetFilePointer(hFileIn,c,0,FILE_CURRENT);
}
}
}
}
ggce.iBlockSize=4;
ggce.iDelayTime=my_delay;
ggce.iDisposalMethod=2;
c=(<span style="color:Blue; char)0x21;
WriteFile(hFileOut,&c,1,&dw,0);
c=(<span style="color:Blue; char)0xF9;
WriteFile(hFileOut,&c,1,&dw,0);
WriteFile(hFileOut,&ggce,<span style="color:Blue; sizeof(GIF_GRAPHIC_CONTROL_EXTENSION),&dw,0);
c=(<span style="color:Blue; char)0x2C;
WriteFile(hFileOut,&c,1,&dw,0);
WriteFile(hFileOut,&gid,<span style="color:Blue; sizeof(GIF_IMAGE_DESCRIPTOR),&dw,0);
WriteFile(hFileOut,szColorTable,iGctSize[gid.iSizeOfLct],&dw,0);
ReadFile(hFileIn,&c,1,&dw,0);
WriteFile(hFileOut,&c,1,&dw,0);
<span style="color:Blue; for (; {
ReadFile(hFileIn,&c,1,&dw,0);
WriteFile(hFileOut,&c,1,&dw,0);
<span style="color:Blue; if (!c) <span style="color:Blue; break;
ReadFile(hFileIn,szColorTable,c,&dw,0);
WriteFile(hFileOut,szColorTable,c,&dw,0);
}
CloseHandle(hFileIn);
}
c=(<span style="color:Blue; char)0x3B;
WriteFile(hFileOut,&c,1,&dw,0);
SetFilePointer(hFileOut,6,0,FILE_BEGIN);
WriteFile(hFileOut,&glsd1,<span style="color:Blue; sizeof(GIF_LOGICAL_SCREEN_DESCRIPTOR),&dw,0);
CloseHandle(hFileOut);
}
}
[/code]
The error is on line: 187 :
<div style="color:Black;background-color:White; <pre>
MessageBox::Show(<span style="color:#A31515; "Not a GIF file, or incorrect version number.");
[/code]
<br/>
Above this line i see two lines wich using gif header and something with cversion 89a and 87a
Im not using c++ so i dont know this language. My brother did this wrapper.
In my c# project to create the gif animated im using .png file and its working on other images im using wich are also .png and the files are seems to be ok so i cant figure out why its throwing this message sometimes.
And i cant use the c++ code in my c# project to check and debug.
Maybe someone here can help me to figure out why im getting this error.
Im sure its a gif file so maybe something with the version ? And version of what ?
Thanks for the help. <hr class="sig danieli
View the full article
On my c# project sometimes when im creating the animated gif im getting the messagebox error.
So this is the code from the c++ before i compile it:
<div style="color:Black;background-color:White; <pre>
#include <span style="color:#A31515; "Stdafx.h"
<span style="color:Green; //#include <windows.h>
<span style="color:Green; //#include <commctrl.h>
<span style="color:Green; //#include <stdio.h>
<span style="color:Green; //#include "res_uf.h"
<span style="color:Blue; using <span style="color:Blue; namespace System::Collections::Generic;
<span style="color:Blue; using <span style="color:Blue; namespace System;
<span style="color:Blue; using <span style="color:Blue; namespace System::Windows::Forms;
<span style="color:Blue; #pragma pack(push,gifpacking,1)
typedef <span style="color:Blue; struct {
<span style="color:Blue; char cSignature[3]; <span style="color:Green; // Must be GIF
<span style="color:Blue; char cVersion[3]; <span style="color:Green; // Must be 89a
} GIF_HEADER;
typedef <span style="color:Blue; struct { <span style="color:Green; // 7 bytes
unsigned <span style="color:Blue; short iWidth;
unsigned <span style="color:Blue; short iHeight;
unsigned <span style="color:Blue; char iSizeOfGct : 3;
unsigned <span style="color:Blue; char iSortFlag : 1;
unsigned <span style="color:Blue; char iColorResolution : 3;
unsigned <span style="color:Blue; char iGctFlag : 1;
unsigned <span style="color:Blue; char iBackgroundColorIndex;
unsigned <span style="color:Blue; char iPixelAspectRatio;
} GIF_LOGICAL_SCREEN_DESCRIPTOR;
typedef <span style="color:Blue; struct { <span style="color:Green; // 6 bytes
unsigned <span style="color:Blue; char iBlockSize; <span style="color:Green; // Must be 4
unsigned <span style="color:Blue; char iTransparentColorFlag : 1;
unsigned <span style="color:Blue; char iUserInputFlag : 1;
unsigned <span style="color:Blue; char iDisposalMethod : 3;
unsigned <span style="color:Blue; char iReserved : 3;
unsigned <span style="color:Blue; short iDelayTime;
unsigned <span style="color:Blue; char iTransparentColorIndex;
unsigned <span style="color:Blue; char iBlockTerminator; <span style="color:Green; // Must be 0
} GIF_GRAPHIC_CONTROL_EXTENSION;
typedef <span style="color:Blue; struct { <span style="color:Green; // 9 bytes
unsigned <span style="color:Blue; short iLeft;
unsigned <span style="color:Blue; short iTop;
unsigned <span style="color:Blue; short iWidth;
unsigned <span style="color:Blue; short iHeight;
unsigned <span style="color:Blue; char iSizeOfLct : 3;
unsigned <span style="color:Blue; char iReserved : 2;
unsigned <span style="color:Blue; char iSortFlag : 1;
unsigned <span style="color:Blue; char iInterlaceFlag : 1;
unsigned <span style="color:Blue; char iLctFlag : 1;
} GIF_IMAGE_DESCRIPTOR;
<span style="color:Blue; #pragma pack(pop,gifpacking)
unsigned <span style="color:Blue; short iGctSize[]={6,12,24,48,96,192,384,768};
<span style="color:Green; //void UpdateFrameInfo(void);
<span style="color:Blue; void __MakeGIF( List<String^> ^file_list , String ^out_file , <span style="color:Blue; int delay , <span style="color:Blue; bool loop );
<span style="color:Green; //HINSTANCE hInst;
<span style="color:Green; //HANDLE hHeap;
<span style="color:Green; /*
void UpdateFrameInfo()
{
DWORD dwIndex, dw;
char sz[256], c;
char *pszFileName;
HANDLE hFile;
GIF_HEADER gh;
GIF_LOGICAL_SCREEN_DESCRIPTOR glsd;
GIF_IMAGE_DESCRIPTOR gid;
ZeroMemory(&gh,sizeof(GIF_HEADER));
ZeroMemory(&glsd,sizeof(GIF_LOGICAL_SCREEN_DESCRIPTOR));
ZeroMemory(&gid,sizeof(GIF_IMAGE_DESCRIPTOR));
dwIndex=SendDlgItemMessage(hMainDlg,IDC_LIST_MAIN_FRAMES,LB_GETCURSEL,0,0);
SendDlgItemMessage(hMainDlg,IDC_LIST_MAIN_FRAMES,LB_GETTEXT,dwIndex,(LPARAM)sz);
pszFileName=(char *)SendDlgItemMessage(hMainDlg,IDC_LIST_MAIN_FRAMES,LB_GETITEMDATA,dwIndex,0);
SetDlgItemText(hMainDlg,IDC_STATIC_MAIN_FILENAME,sz);
hFile=CreateFile(pszFileName,GENERIC_READ,FILE_SHARE_READ,0,OPEN_EXISTING,FILE_FLAG_SEQUENTIAL_SCAN,0);
if (hFile==INVALID_HANDLE_VALUE) {
MessageBox(hMainDlg,"Could not open file.",0,MB_ICONEXCLAMATION);
return;
}
ReadFile(hFile,&gh,sizeof(GIF_HEADER),&dw,0);
if (strncmp(gh.cSignature,"GIF",3) || (strncmp(gh.cVersion,"89a",3) && strncmp(gh.cVersion,"87a",3))) {
MessageBox(hMainDlg,"Not a GIF file, or incorrect version number.",0,MB_ICONEXCLAMATION);
CloseHandle(hFile);
return;
}
ReadFile(hFile,&glsd,sizeof(GIF_LOGICAL_SCREEN_DESCRIPTOR),&dw,0);
if (glsd.iGctFlag) SetFilePointer(hFile,iGctSize[glsd.iSizeOfGct],0,FILE_CURRENT);
for (; {
ReadFile(hFile,&c,1,&dw,0);
if (dw==0) {
MessageBox(hMainDlg,"Premature end of file encountered; no GIF image data present.",0,MB_ICONEXCLAMATION);
CloseHandle(hFile);
return;
}
if (c==0x2C) {
ReadFile(hFile,&gid,sizeof(GIF_IMAGE_DESCRIPTOR),&dw,0);
break;
} else if (c==0x21) {
ReadFile(hFile,&c,1,&dw,0);
if (c==0xF9) {
SetFilePointer(hFile,sizeof(GIF_GRAPHIC_CONTROL_EXTENSION),0,FILE_CURRENT);
} else {
for (; {
ReadFile(hFile,&c,1,&dw,0);
if (!c) break;
SetFilePointer(hFile,c,0,FILE_CURRENT);
}
}
}
}
CloseHandle(hFile);
sprintf(sz,"%d x %dn%s (%d bpp)",glsd.iWidth,glsd.iHeight,gid.iLctFlag?"local"glsd.iGctFlag?"global":"none"),gid.iLctFlag?(gid.iSizeOfLct+1)glsd.iSizeOfGct+1));
SetDlgItemText(hMainDlg,IDC_STATIC_MAIN_INFO,sz);
}
*/
<span style="color:Blue; void __MakeGIF( List<String^> ^file_list , String ^out_file , <span style="color:Blue; int my_delay , <span style="color:Blue; bool is_loop )
{
DWORD dwIndex, dw;
<span style="color:Blue; char szColorTable[768];
unsigned <span style="color:Blue; char c;
HANDLE hFileOut, hFileIn;
GIF_HEADER gh;
GIF_LOGICAL_SCREEN_DESCRIPTOR glsd1, glsd;
GIF_GRAPHIC_CONTROL_EXTENSION ggce;
GIF_IMAGE_DESCRIPTOR gid;
ZeroMemory(&glsd1,<span style="color:Blue; sizeof(GIF_LOGICAL_SCREEN_DESCRIPTOR));
<span style="color:Green; // new vars
DWORD total_files=file_list->Count;
<span style="color:Blue; char szFileName[MAX_PATH];
<span style="color:Blue; int i;
List<String^> ^fl = file_list;
<span style="color:Blue; for (i=0;i<out_file->Length;i++)
szFileName = (<span style="color:Blue; char)out_file;
szFileName = 0;
<span style="color:Blue; char current_file_name[MAX_PATH];
<span style="color:Blue; if (1)
{
hFileOut=CreateFile(szFileName,GENERIC_WRITE,FILE_SHARE_READ,0,CREATE_ALWAYS,0,0);
<span style="color:Green; //strncpy_s((char *)&gh,6,"GIF89a",6);
((<span style="color:Blue; char *)&gh)[0] = <span style="color:#A31515; G;
((<span style="color:Blue; char *)&gh)[1] = <span style="color:#A31515; I;
((<span style="color:Blue; char *)&gh)[2] = <span style="color:#A31515; F;
((<span style="color:Blue; char *)&gh)[3] = <span style="color:#A31515; 8;
((<span style="color:Blue; char *)&gh)[4] = <span style="color:#A31515; 9;
((<span style="color:Blue; char *)&gh)[5] = <span style="color:#A31515; a;
WriteFile(hFileOut,&gh,<span style="color:Blue; sizeof(GIF_HEADER),&dw,0);
WriteFile(hFileOut,&glsd1,<span style="color:Blue; sizeof(GIF_LOGICAL_SCREEN_DESCRIPTOR),&dw,0);
<span style="color:Blue; if (is_loop==<span style="color:Blue; true)
{
WriteFile(hFileOut,<span style="color:#A31515; "41377 13NETSCAPE2.001377377 ",19,&dw,0);
}
<span style="color:Blue; for (dwIndex=0;dwIndex<total_files;dwIndex++)
{
ZeroMemory(&glsd,<span style="color:Blue; sizeof(GIF_LOGICAL_SCREEN_DESCRIPTOR));
ZeroMemory(&ggce,<span style="color:Blue; sizeof(GIF_GRAPHIC_CONTROL_EXTENSION));
ZeroMemory(&gid,<span style="color:Blue; sizeof(GIF_IMAGE_DESCRIPTOR));
<span style="color:Blue; for (i=0;i<fl[dwIndex]->Length;i++)
current_file_name = (<span style="color:Blue; char)fl[dwIndex];
current_file_name=0;
hFileIn=CreateFile(current_file_name,GENERIC_READ,FILE_SHARE_READ,0,OPEN_EXISTING,FILE_FLAG_SEQUENTIAL_SCAN,0);
<span style="color:Blue; if (hFileIn==INVALID_HANDLE_VALUE) {
DWORD err = GetLastError();
MessageBox::Show(<span style="color:#A31515; "Could not open file. GIF creation aborted. : " + Convert::ToString((unsigned <span style="color:Blue; int)err) );
CloseHandle(hFileOut);
<span style="color:Blue; return;
}
ReadFile(hFileIn,&gh,<span style="color:Blue; sizeof(GIF_HEADER),&dw,0);
<span style="color:Blue; if (strncmp(gh.cSignature,<span style="color:#A31515; "GIF",3) || (strncmp(gh.cVersion,<span style="color:#A31515; "89a",3) && strncmp(gh.cVersion,<span style="color:#A31515; "87a",3))) {
MessageBox::Show(<span style="color:#A31515; "Not a GIF file, or incorrect version number.");
CloseHandle(hFileIn);
CloseHandle(hFileOut);
<span style="color:Blue; return;
}
ReadFile(hFileIn,&glsd,<span style="color:Blue; sizeof(GIF_LOGICAL_SCREEN_DESCRIPTOR),&dw,0);
<span style="color:Blue; if (glsd.iGctFlag) ReadFile(hFileIn,szColorTable,iGctSize[glsd.iSizeOfGct],&dw,0);
<span style="color:Blue; if (glsd1.iWidth<glsd.iWidth) glsd1.iWidth=glsd.iWidth;
<span style="color:Blue; if (glsd1.iHeight<glsd.iHeight) glsd1.iHeight=glsd.iHeight;
<span style="color:Blue; for (; {
ReadFile(hFileIn,&c,1,&dw,0);
<span style="color:Blue; if (dw==0) {
MessageBox::Show(<span style="color:#A31515; "Premature end of file encountered; no GIF image data present.");
CloseHandle(hFileIn);
CloseHandle(hFileOut);
<span style="color:Blue; return;
}
<span style="color:Blue; if (c==0x2C) {
ReadFile(hFileIn,&gid,<span style="color:Blue; sizeof(GIF_IMAGE_DESCRIPTOR),&dw,0);
<span style="color:Blue; if (gid.iLctFlag) {
ReadFile(hFileIn,szColorTable,iGctSize[gid.iSizeOfLct],&dw,0);
} <span style="color:Blue; else {
gid.iLctFlag=1;
gid.iSizeOfLct=glsd.iSizeOfGct;
}
<span style="color:Blue; break;
} <span style="color:Blue; else <span style="color:Blue; if (c==0x21) {
ReadFile(hFileIn,&c,1,&dw,0);
<span style="color:Blue; if (c==0xF9) {
ReadFile(hFileIn,&ggce,<span style="color:Blue; sizeof(GIF_GRAPHIC_CONTROL_EXTENSION),&dw,0);
} <span style="color:Blue; else {
<span style="color:Blue; for (; {
ReadFile(hFileIn,&c,1,&dw,0);
<span style="color:Blue; if (!c) <span style="color:Blue; break;
SetFilePointer(hFileIn,c,0,FILE_CURRENT);
}
}
}
}
ggce.iBlockSize=4;
ggce.iDelayTime=my_delay;
ggce.iDisposalMethod=2;
c=(<span style="color:Blue; char)0x21;
WriteFile(hFileOut,&c,1,&dw,0);
c=(<span style="color:Blue; char)0xF9;
WriteFile(hFileOut,&c,1,&dw,0);
WriteFile(hFileOut,&ggce,<span style="color:Blue; sizeof(GIF_GRAPHIC_CONTROL_EXTENSION),&dw,0);
c=(<span style="color:Blue; char)0x2C;
WriteFile(hFileOut,&c,1,&dw,0);
WriteFile(hFileOut,&gid,<span style="color:Blue; sizeof(GIF_IMAGE_DESCRIPTOR),&dw,0);
WriteFile(hFileOut,szColorTable,iGctSize[gid.iSizeOfLct],&dw,0);
ReadFile(hFileIn,&c,1,&dw,0);
WriteFile(hFileOut,&c,1,&dw,0);
<span style="color:Blue; for (; {
ReadFile(hFileIn,&c,1,&dw,0);
WriteFile(hFileOut,&c,1,&dw,0);
<span style="color:Blue; if (!c) <span style="color:Blue; break;
ReadFile(hFileIn,szColorTable,c,&dw,0);
WriteFile(hFileOut,szColorTable,c,&dw,0);
}
CloseHandle(hFileIn);
}
c=(<span style="color:Blue; char)0x3B;
WriteFile(hFileOut,&c,1,&dw,0);
SetFilePointer(hFileOut,6,0,FILE_BEGIN);
WriteFile(hFileOut,&glsd1,<span style="color:Blue; sizeof(GIF_LOGICAL_SCREEN_DESCRIPTOR),&dw,0);
CloseHandle(hFileOut);
}
}
[/code]
The error is on line: 187 :
<div style="color:Black;background-color:White; <pre>
MessageBox::Show(<span style="color:#A31515; "Not a GIF file, or incorrect version number.");
[/code]
<br/>
Above this line i see two lines wich using gif header and something with cversion 89a and 87a
Im not using c++ so i dont know this language. My brother did this wrapper.
In my c# project to create the gif animated im using .png file and its working on other images im using wich are also .png and the files are seems to be ok so i cant figure out why its throwing this message sometimes.
And i cant use the c++ code in my c# project to check and debug.
Maybe someone here can help me to figure out why im getting this error.
Im sure its a gif file so maybe something with the version ? And version of what ?
Thanks for the help. <hr class="sig danieli
View the full article