hi,
i would like to discuss an old problem that i had, again. perhaps it's explained better this time.
ok, i want to program a game that uses a lot of big-in-size images. so i thought that it would be
better to convert them to GIFs and use exagone's giflib. first everything worked fine. some hours
later i had to add very much and long strings to my .code section. it became bigger and bigger,
until i noticed that my GIFs don't load correctly after a number of strings defined in my .code
section. i tried everything, i defined the images in the resource file in different orders, i defined
the strings in different orders, nothing worked. After some time exagone noticed that he didn't clean
some things up in his giflib. he changed that, but still, the images didn't load correctly. when i say
that the images didn't load correctly, i mean, that in every place where a gif should be, there was
always the first gif defined in the resource file. some people told me that some headers or sections
in the PE file could be damaged, but i've no idea about that stuff. i had a look at the exe with
eXeScope and found out that the images are ok in the exe. so there must be something else with it.
perhaps now, somebody of you has an idea about that problem.

I also attached the whole source if someone needs more information. but i didn't include all the
gifs, the file would be too large. please compile the RC file and the whole project yourself.
because of the gifs, this files would be too large. when you compile the RC-file, you can leave
the missing gifs out. it is not important how many gifs are defined in the resource file, the .data
section seems to be the problem.
Following there is the resource file, some parts of the asm-file and the compiling parameters:

resource file:
~~~~~~~~~~~~~~


6002 RCDATA "wuerf.gif"
6003 RCDATA "wuerf2.gif"
6004 RCDATA "daumen.gif"
6005 RCDATA "daumen2.gif"
6006 RCDATA "handel.gif"
6010 RCDATA "wuerfzahl.gif"
5000 RCDATA "logo.gif"
5001 RCDATA "kleinlogo.gif"
5002 RCDATA "feld.gif"
6000 RCDATA "bdetails.gif"
6001 RCDATA "bdetails2.gif"
6007 RCDATA "handel2.gif"
6008 RCDATA "ende.gif"
6009 RCDATA "ende2.gif"


some important parts of the asm-file:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
this is how i tried to load the gif:
possibility 1:


invoke FindResource,hInstance,5000,RT_RCDATA
mov RsrcHand, eax
invoke LoadResource,hInstance,eax
mov RsrcPoint, eax
invoke SizeofResource,hInstance,RsrcHand
mov RsrcSize, eax
invoke LockResource,RsrcPoint
mov RsrcPoint, eax
mov logogif.lpGIFData,eax
push RsrcSize
pop logogif.dwGIFDataSize
invoke GIFLoadHeader, ADDR logogif
invoke GIFInitalizeDecoder, ADDR logogif
invoke CreateCompatibleDC,myDC
mov logobmp,eax
invoke GIFGetMinimumColorType, ADDR logogif
mov logogif.dwImageFormat, eax
invoke GIFFillBitmapInfoStruct, ADDR logogif, ADDR BitmapInfo
invoke GIFGetColorTable, ADDR logogif, ADDR ColorTable
invoke CreateDIBSection, myDC, ADDR BitmapInfo, DIB_RGB_COLORS,\
ADDR bitptr, NULL, NULL
mov hlogobmp, eax
invoke ReleaseDC,hWin,myDC
invoke SelectObject, logobmp, hlogobmp
push bitptr
pop logogif.lpImageData
invoke GIFDecompress, ADDR logogif
invoke GIFCleanup, addr logogif


possibility 2:


invoke GIFLoadResource, ADDR logogif, hInstance,5000
invoke GIFLoadHeader, ADDR logogif
invoke GIFInitalizeDecoder, ADDR logogif
invoke CreateCompatibleDC,myDC
mov logobmp,eax
invoke GIFGetMinimumColorType, ADDR logogif
mov logogif.dwImageFormat, eax
invoke GIFFillBitmapInfoStruct, ADDR logogif, ADDR BitmapInfo
invoke GIFGetColorTable, ADDR logogif, ADDR ColorTable
invoke CreateDIBSection, myDC, ADDR BitmapInfo, DIB_RGB_COLORS,\
ADDR bitptr, NULL, NULL
mov hlogobmp, eax
invoke ReleaseDC,hWin,myDC
invoke SelectObject, logobmp, hlogobmp
push bitptr
pop logogif.lpImageData
invoke GIFDecompress, ADDR logogif
invoke GIFCleanup, addr logogif


the two possibilities work, but they didn't solve my problem.

the batch file to compile the project (it isn't perfect, i know):
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


@echo off

: -------------------------------
: if resources exist, build them
: -------------------------------
if not exist C:\masm32\bin\safcon\%1\%1.rc goto over1
C:\masm32\BIN\RC.EXE /v C:\masm32\bin\safcon\%1\%1.rc
:C:\masm32\BIN\CVTRES.EXE /machine:ix86 C:\masm32\bin\safcon\%1\%1.res
:over1

if exist C:\masm32\bin\safcon\%1\%1.obj del C:\masm32\bin\safcon\%1\%1.obj
if exist C:\masm32\bin\safcon\%1\%1.exe del C:\masm32\bin\safcon\%1\%1.exe

: -----------------------------------------
: assemble *.asm into an OBJ file
: -----------------------------------------
ml /c /coff /Cp C:\masm32\bin\safcon\%1\%1.asm
if errorlevel 1 goto errasm
copy C:\masm32\bin\%1.obj C:\masm32\bin\safcon\%1\%1.obj
del C:\masm32\bin\%1.obj

if not exist C:\masm32\bin\safcon\%1\%1.res goto nores

: --------------------------------------------------
: link the main OBJ file with the resource OBJ file
: --------------------------------------------------
C:\masm32\BIN\LINK.EXE /SUBSYSTEM:WINDOWS C:\masm32\bin\safcon\%1\%1.obj safcon\%1\%1.res
if errorlevel 1 goto errlink
copy C:\masm32\bin\%1.exe C:\masm32\bin\safcon\%1\%1.exe
del C:\masm32\bin\%1.exe
dir C:\masm32\bin\safcon\%1\%1.*
C:\masm32\bin\safcon\%1\%1
goto TheEnd

:nores
: -----------------------
: link the main OBJ file
: -----------------------
C:\masm32\BIN\LINK.EXE /SUBSYSTEM:WINDOWS C:\masm32\bin\safcon\%1\%1.obj
if errorlevel 1 goto errlink
copy C:\masm32\bin\%1.exe C:\masm32\bin\safcon\%1\%1.exe
del C:\masm32\bin\%1.exe
dir C:\masm32\bin\safcon\%1\%1.*
rem C:\masm32\bin\safcon\%1\%1
goto TheEnd

:errlink
: ----------------------------------------------------
: display message if there is an error during linking
: ----------------------------------------------------
echo.
echo There has been an error while linking this project.
echo.
goto TheEnd

:errasm
: -----------------------------------------------------
: display message if there is an error during assembly
: -----------------------------------------------------
echo.
echo There has been an error while assembling this project.
echo.
goto TheEnd

:TheEnd


i would appreceiate any help!

[-alloces-]
Posted on 2001-07-28 03:38:55 by NOP-erator
I had a problems with giflib.I guess main problem is you should protect


TestGif GIF_INFO <>
hDCBitmap dd ?
hBitmap dd ?
BitmapInfo BITMAPINFOHEADER <>
ColorTable db 32*4 dup (?)


I guess order is important too.I add this to end of .data? section and I load file from resource.However I havent tried with more than one file.
Posted on 2001-07-28 07:07:38 by LaptoniC
sorry, but i don't understand what you mean with that... :confused:
Posted on 2001-07-28 07:48:20 by NOP-erator
What I mean is do not put giflib varibles to begining of .data? section.Because sometimes this values are overwritten.When I was saying protecting I mean to protect this varibles.I dont know if your problems are arise from this.Ohh btw there is another method to load gif and jpeg files.Check Ernie's page.
Posted on 2001-07-28 09:45:37 by LaptoniC
I've loaded GIFs using the microsoft API for this direct from files, it had no such 'issues.' This method doesn't use resources, but you could always copy out the gif to a temp file and load that.

My tut is at: http://here.is/COMinASM (way at the bottom)

Also, Barry Kauler did a version without using my CoLib stuff you may like better. His work is at: http://www4.tpg.com.au/users/void/x86
Posted on 2001-07-28 10:13:35 by Ernie
ok, i looked at ernie's stuff and the other one. it seems to be complicated (at least for me). i have to read that carefully and spend many time with it, if i'll use that.

BUT: LaptoniC, I tried to put the variables needed to load the gif at the beginning of the .data? section, and imagine what happened! no, it didn't work :( , but the program crashed when i ran it. it didn't even show the window, it crashed immediately! i've to look over that with a debugger, but thanks for the hint!

perhaps someone of you know why it crashes if i put the last 4 variables of .data? section at the beginning? seems that i've made something wrong with defining the other variables. hmmmm, very strange.....

[-alloces-]
Posted on 2001-07-28 11:22:54 by NOP-erator
ok, it seems that it is a problem with defining my data. if i put the last 4 variables some lines higher, no gif is shown. if it is at the bottom, at least the first gif in the resource is shown. if the 4 variables are at the beginning of .data? section, the program crashes at the first GIFDecompress. (so there's perhaps something wrong with the variable logogif (type: GIF_INFO).

perhaps someone of you can look again over my .data and .data? section if i forgot something? the problem must be there. that would be very nice.
Posted on 2001-07-29 06:17:55 by NOP-erator
Hi,

I darkly remember some problems loading large binaries from resources. There is a tool called fixres95.exe from microshit. There were several problems loading resources larger than 64k.

Guess the best way is to load this data from
files.

Bye Miracle
Posted on 2001-07-30 08:03:47 by miracle
Could you please attach the GIFLIB package?
Posted on 2003-07-10 03:38:49 by inFinie
Thomas removed it from his site I think.... Maybe some of the members still have it.
Posted on 2003-07-10 03:45:27 by roticv
Do you mean Exagone's Gif Library 1.0?
It's available for download on Page 3 of the Examples
and Source code section of Iczelion's Win32 Assembly Homepage .
Posted on 2003-07-11 20:12:15 by Poimander
I removed it because of license issues but it probably has been there long enough to still find it on the net. Unless you're required to use GIFs I recommend to use PNGs and my PNGlib.

Thomas
Posted on 2003-07-20 03:27:59 by Thomas