flat assembler
Message board for the users of flat assembler.

Index > Windows > download a gif from internet and show it in window

Goto page 1, 2  Next
Author
Thread Post new topic Reply to topic
sina



Joined: 18 Aug 2003
Posts: 132
Location: istanbul turkey
sina
ok i am gonna retrieve a gif file by using the method
inskipp has told here

http://board.flatassembler.net/topic.php?t=1434

and i will have the gif file in the buffer

now to show the gif on my window;

in the giflib by exagone which is ported to fasm by JohnFound

there r 2 stdcalls
GIFLoadResource
GIFLoadFile

as it is not in the resource and i dont think putting it in res is wise, if it can be Smile
so i will use GIFLoadFile
now should i first save the buffer to a file and then open it and use GIFLoadFile, or there is a shortcut to do it with the buffer?

anyway i wanted to ask this before coding

ps: i also appreciate helps on puttin the buffer to a file
Post 27 Dec 2004, 17:51
View user's profile Send private message ICQ Number Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3502
Location: Bulgaria
JohnFound
Actually GIFLoadResource and GIFLoadFile shold not be called directly. They only load gif image from resource/file into the memory and set internal TGifFile structure fields.

In giflib.asm you should check the procedure "DoLoadGif" this is the only procedure that creates DIB bitmap from GIF image. It uses as first call GIFLoadResource, but you can modify it to use GIFLoadFile, or even to skip this stage and to fill TGifImage fields with appropriate pointers to memory image. (check .lpGIFData field). After loading of compressed image, there are several stages to be called in order to uncompess the image and to create DIB bitmap.

This all is on prima vista, because I wrote this port some time ago and probably I forgot some details.

Regards.
Post 27 Dec 2004, 18:23
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3502
Location: Bulgaria
JohnFound
Actually GIFLoadResource and GIFLoadFile shold not be called directly. They only load gif image from resource/file into the memory and set internal TGifFile structure fields.

In giflib.asm you should check the procedure "DoLoadGif" this is the only procedure that creates DIB bitmap from GIF image. It uses as first call GIFLoadResource, but you can modify it to use GIFLoadFile, or even to skip this stage and to fill TGifImage fields with appropriate pointers to memory image. (check .lpGIFData field). After loading of compressed image, there are several stages to be called in order to uncompess the image and to create DIB bitmap.

This all is on prima vista, because I wrote this port some time ago and probably I forgot some details.

Regards.
Post 27 Dec 2004, 18:23
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
sina



Joined: 18 Aug 2003
Posts: 132
Location: istanbul turkey
sina
thx johnfound i will try to do it
lets see Smile
Post 27 Dec 2004, 20:13
View user's profile Send private message ICQ Number Reply with quote
sina



Joined: 18 Aug 2003
Posts: 132
Location: istanbul turkey
sina
err johnfound, i have downloaded an old one of giflib i think becouse i did not have doloadgif and now i have downloaded the latest fresh and using the ones inside it with doloadgif, i think they r the most uptodate ones
Post 27 Dec 2004, 22:38
View user's profile Send private message ICQ Number Reply with quote
sina



Joined: 18 Aug 2003
Posts: 132
Location: istanbul turkey
sina
err hi again johnfound,and others if anyone watching this thread

so look at my modification to the doloadgif pls

Code:
;proc DoLoadGif, .hInst, .ptrName, .ptrGifInfo
proc DoLoadGif, .ptrFile, .ptrGifInfo
.bitmapinfo BITMAPINFOHEADER
.result     dd ?
begin
        push    esi edi
        mov     [.result], 0

        mov     edi, [.ptrGifInfo]
        lea     esi, [.bitmapinfo]

;        stdcall GIFLoadResource, edi, [.hInst], [.ptrName]
        stdcall GIFLoadFile, edi, [.ptrFile]
        jz      .quit

        stdcall GIFLoadHeader, edi
        jz      .quit

        stdcall GIFInitalizeDecoder, edi
        jz       .quit

        stdcall GIFFillBitmapInfoStruct, edi, esi

        lea     eax, [edi+TGifInfo.lpImageData]
        invoke  CreateDIBSection, NULL, esi, DIB_RGB_COLORS, eax, NULL, NULL
        test    eax, eax
        jz      .quit

        mov     [.result], eax

        stdcall GIFDecompress, edi
        jz      .quit

        stdcall GIFCleanup, edi

.quit:
        mov     eax, [.result]
        pop     edi esi
        return
endp
    


after using .ptrFile i should clean it up right? and how?

Code:
        push    esi
        mov     esi, [.ptrFile]
        invoke  GetProcessHeap
        invoke  HeapFree, eax, 0, [esi+something]
        pop     esi
        return
    


am i going near?

and after these can u show me the way for showing the dib image on the window, i have an example u have wrriten with the old giflib.asm i told u, v1.1 using ImageList_LoadGif, but that did not give me ideas
Post 27 Dec 2004, 23:00
View user's profile Send private message ICQ Number Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3502
Location: Bulgaria
JohnFound
VeSCeRa wrote:
after using .ptrFile i should clean it up right? and how?


Hm, GIFLoadFile allocates one memory buffer to store the compressed .gif image as it was in the file. After the decompression, you don't need this buffer and you have to free it with HeapFree, somewhere at the end of DoLoadGif. Something like:

Code:
        mov     esi, [.lpGifInfo]
        invoke  GetProcessHeap
        invoke  HeapFree, eax, 0, [esi+TGifInfo.lpGIFData]
    


[.ptrFile] is simply a string. You have to deal with it only if you dynamically allocated its buffer from the heap.

Quote:
and after these can u show me the way for showing the dib image on the window, i have an example u have wrriten with the old giflib.asm i told u, v1.1 using ImageList_LoadGif, but that did not give me ideas


Well, you can use the handle to the DIB like every other bitmap. You can assign it to STATIC control (with SS_BITMAP style set) with STM_SETIMAGE message, also, you can create compatible DC and draw it to another (screen) DC using BitBlt, StretchBlt, etc. etc.

P.S. Why not to modify DoLoadGif to load resource is [.hInst] <> -1 and to load a file is [.hInst] = -1 (or to introduce new argument .fLoadFromFile)?

Regards
Post 27 Dec 2004, 23:21
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
sina



Joined: 18 Aug 2003
Posts: 132
Location: istanbul turkey
sina
hmm first johnfound i like u becouse u r wise Smile and u always have quick replies thx for that
and second excuse me but i could not understand what u mean here;
Quote:

Why not to modify DoLoadGif to load resource is [.hInst] <> -1 and to load a file is [.hInst] = -1 (or to introduce new argument .fLoadFromFile)?


is my modification useless?

ps: i must go to university now Sad , i wish Thomasz would port fasm to symbian phones Smile then i would try on my ngage phone Razz
Post 28 Dec 2004, 10:09
View user's profile Send private message ICQ Number Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3502
Location: Bulgaria
JohnFound
VeSCeRa wrote:
is my modification useless?


No at all. I simply though to use one DoLoadGif procedure for both resources and files depending on input arguments. And there is mistake in my post - read "is" as "if". Smile

johnfound wrote:

Why not to modify DoLoadGif to load resource if [.hInst] <> -1 and to load a file if [.hInst] = -1 (or to introduce new argument .fLoadFromFile)?


Regards
Post 28 Dec 2004, 10:18
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
sina



Joined: 18 Aug 2003
Posts: 132
Location: istanbul turkey
sina
hmm what about this
please check this Smile
Code:
proc DoLoadGif, .hInst, .ptrName, .ptrGifInfo
.bitmapinfo BITMAPINFOHEADER
.result     dd ?
begin

        push    esi edi
        mov     [.result], 0

        mov     edi, [.ptrGifInfo]
        lea     esi, [.bitmapinfo]

        cmp     [.hInst], -1
        je      @f    

        stdcall GIFLoadResource, edi, [.hInst], [.ptrName]
        jz      .quit
 jmp     .gifloadheader

@@:
       stdcall GIFLoadFile, edi, [.ptrName]
        jz      .quit

.gifloadheader:
        stdcall GIFLoadHeader, edi
        jz      .quit

        stdcall GIFInitalizeDecoder, edi
        jz       .quit

        stdcall GIFFillBitmapInfoStruct, edi, esi

        lea     eax, [edi+TGifInfo.lpImageData]
        invoke  CreateDIBSection, NULL, esi, DIB_RGB_COLORS, eax, NULL, NULL
        test    eax, eax
        jz      .quit

        mov     [.result], eax

        stdcall GIFDecompress, edi
        jz      .quit

        stdcall GIFCleanup, edi

.quit:
        mov     eax, [.result]
        pop     edi esi
        return
endp
    
Post 28 Dec 2004, 19:02
View user's profile Send private message ICQ Number Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3502
Location: Bulgaria
JohnFound
VeSCeRa wrote:
hmm what about this
please check this Smile


Yes, that was exactly what I meant. I have no time to test it actually, but it seems OK. Please provide some feedback, when you make it work. I will include it in giflib.

Regards.
Post 28 Dec 2004, 20:03
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
sina



Joined: 18 Aug 2003
Posts: 132
Location: istanbul turkey
sina
now i had removed some hair from my head!

ok i needed to modify giflib.asm and giflib.inc a bit more to get rid of syntax errors

but the Loadgif procedure, or if i call it from Doloadgif it does not matter crashes and i could not find out what is wrong

my code is messy i know but i can only code in midnights becouse of the lack of time, if i can get rid of this gif to dib issue i will clean it but first i want to have that gif file on my static

now it downloads 4 gif files, the messageboxes try to show the buffer of gif files and then they r saved to c:\temp?.gif
and when i try to open first one it crashes on Loadgif


Description:
Download
Filename: weather.rar
Filesize: 12.48 KB
Downloaded: 110 Time(s)

Post 28 Dec 2004, 23:45
View user's profile Send private message ICQ Number Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3502
Location: Bulgaria
JohnFound
VeSCeRa wrote:
now i had removed some hair from my head!


Right approach. Very Happy Now I see. You MUST use Fresh "StrCallEx.inc" library with "giflib.asm" or entirely rewrite it to use FASM standard for procedures. Simply commenting "begin" statements wouldn't help...

Regards
Post 29 Dec 2004, 00:26
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
sina



Joined: 18 Aug 2003
Posts: 132
Location: istanbul turkey
sina
i dont think that is the only one to include
can u tell me what other files to include from frash libs

when i try to compile it says

purge errendp#open@proc

extra chars in bla bla in stdcallex.inc
Post 29 Dec 2004, 17:27
View user's profile Send private message ICQ Number Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3502
Location: Bulgaria
JohnFound
At least, if you really want to use FASM includes, you have not to include the file "stdcall.inc" from the FASM include library, but to use "StdCallEx.inc" from the Fresh package. Then you have to use following procedure schema for your own application as well:
Code:
proc someproc, arg, arg, ...
  ;local variables declarations
begin
  ; code of the procedure
  return  ; there can be more than one.
endp
    


You must not include both "stdcall.inc" and "StdCallEx.inc" at the same source. With these macroses, giflib.asm should be compiled normally. (only don't forget to restore "begin" statements you commented, or better restore whole file from the archive.)

Regards
Post 29 Dec 2004, 19:48
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
sina



Joined: 18 Aug 2003
Posts: 132
Location: istanbul turkey
sina
hmm these r my includes

include 'stdcallex.inc'
include 'struct.inc'
include 'giflib.inc'
include '%fasminc%\win32ax.inc'

how can i not include stdcall.inc
Post 29 Dec 2004, 20:13
View user's profile Send private message ICQ Number Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3502
Location: Bulgaria
JohnFound
VeSCeRa wrote:
hmm these r my includes

include 'stdcallex.inc'
include 'struct.inc'
include 'giflib.inc'
include '%fasminc%\win32ax.inc'

how can i not include stdcall.inc


Well, you have to remove it from '%fasminc%\win32ax.inc'. Or you can use only Fresh libraries: Try "File|New application" and then choose "Win32 SDI tiny application". Smile

Regards.

P.S. Only use the latest work release of Fresh.
Post 29 Dec 2004, 21:05
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
sina



Joined: 18 Aug 2003
Posts: 132
Location: istanbul turkey
sina
err i have replaced all fasm includes with fresh ones but still i got errors

i think it is better to port giflib to fasm includes version

but i think i am losing power and concentration here
Post 29 Dec 2004, 21:05
View user's profile Send private message ICQ Number Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3502
Location: Bulgaria
JohnFound
VeSCeRa wrote:
err i have replaced all fasm includes with fresh ones but still i got errors


OK, post your latest version here (or sent it to my email) and I will try to fix it. If you replaced StdCall.inc there should be only some minor problems.

Regards.
Post 29 Dec 2004, 21:14
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
sina



Joined: 18 Aug 2003
Posts: 132
Location: istanbul turkey
sina
yes the problem is in my dialogproc

Code:
proc DialogProc, hwnddlg, msg, wparam, lparam
begin
        push    ebx esi edi
        mov     eax, [msg]
        cmp     eax,WM_COMMAND
        je      wmcommand
        cmp     eax,WM_DESTROY
        je      wmdestroy
        xor     eax,eax
        jmp     finish
    

it says ERROR! the argument 'hwnddlg' MUST begins with dot then when i add dots to the arguments it says if .__info.frame undefined symbol at begin Smile
Post 30 Dec 2004, 15:58
View user's profile Send private message ICQ Number Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  
Goto page 1, 2  Next

< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar. Also on YouTube, Twitter.

Website powered by rwasa.