News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

Viewing Animated GIF files

Started by bluedevil, May 18, 2017, 02:31:14 AM

Previous topic - Next topic

avcaballero

Don't you sleep? :biggrin:

>use SetTimer to call InvalidateRect
I do it in this way

>What exactly do you do when the size changes?
It is in the code. With regarding to gdi+:
* I create a gdi+bitmap
* I create a gdi+double_buffer
Previously I delete both, otherwise the size of the program will increase without stop. Unfortunately, its size grows even if you reduce the size of the screen. I imagine it must create something internally that we are not destroying previously.

Another possibility is to make it in gdi (not +). One day, when I have time.

Edited: Now you can choose another gif file pressing the "1" button.

avcaballero

Is there no way to change the attached zip file when editing the post? ::)

Well, a fixed version for an small issue on the string filter for opening a file.

jj2007

Quote from: newrobert on May 27, 2017, 06:02:25 PM
Olly,this software seems not to download.

Just tested, it works: direct link to zip file.

Quote from: caballero on May 27, 2017, 08:07:05 PM
Is there no way to change the attached zip file when editing the post? ::)

Shouldn't be a problem. Just uncheck the current attachment, then add a new one. It is a good idea to use a new name for the new attachment, as either browsers or the SMF software may give users the old cached one if you use the same name again.

Re leaks, here is what I get with some diagnostic code added:** line 195, GdipGraphicsClear                InvalidParameter
** line 196, GdipDrawImageRectI               InvalidParameter
** line 202, GdipDrawImagePointRectI          InvalidParameter
** line 301, GdipDeleteGraphics               ObjectBusy
...
** line 301, GdipDeleteGraphics               ObjectBusy
** line 272, GdipFree                         GenericError


The line 301 error appears every time when you resize the window. And as soon as you put the correct call there, all is fine with the working set, no more leak ;)

Apologies that this requires MasmBasic :bgrin:
Open the *.asc in RichMasm and hit F6. Press Ctrl G to insert the line number. I have changed only
- a handful of lines on top,
- gsi->Gsi because of a name conflict,
- invoke Gdi** -> invGdip Gdi**

avcaballero

No, I'm not able to change the f**cking file. Well, it is good to read the docs :lol: better use "GdipDisposeImage" for delete the gdi+ bitmap than "GdipDeleteGraphics" :greenclp:

Well, here it is the new working version. Now the mem size decreases when the window is aminorated. Nevertheless I have noticed that it size increases with no reason when the gif is changed. :icon_rolleyes:

jj2007

Quote from: caballero on May 27, 2017, 10:21:48 PM
Well, it is good to read the docs :lol: better use "GdipDisposeImage"

Yes, RTFM is always a good idea. But it's much easier if you know that the culprit is GdipDeleteGraphics in line 301 :P

You still have 3*InvalidParameter to solve, but these calls are apparently not necessary.

avcaballero

> I have noticed that it size increases with no reason when the gif is changed.
For that, it is convenient to erase the objects before loading the new gif, as we have done in the resize section. With that it gets quite accurate. I left it to the good reader :t

avcaballero

Hello. A revision of the animated gif viewer with gdi+. This enhanced version work well with all the compilers: fasm, masm, nasmx, PellesC and TinyC for win32 and win64. Now transparent gifs do not blur the background. Besides now you can open any other gif than the default one, bearing in mind that need to use unicode chars for that.

jj2007

It works fine now, but I see big differences between your display and mine. Is it the smoothing?

Attached an example - drag the tweety over ImageInfo.exe to see my version, press "0" in GDIPlusWM01.exe to open the GIF.

P.S.: Another odd thing is that the gangster appears far too small on launch, i.e. I have to resize the window to see it properly. In contrast, the tweety appears with the correct size.

avcaballero

I only get the error "Error leyendo gif" twice

jj2007

Even if you extract all three files to the same folder and launch the exe from there?

Oops, I forgot that it expects gangster.gif there, too; this is your original code with the hard-coded path.

- re size of Gangster: you get the correct values, but Windows imposes a minimum width for the main window (your code is OK)
- I got an "unknown error" for the two GdipAlloc calls, but your code is OK: MSDN is wrong, GdipAlloc does not return a GpStatus but rather a pointer.

avcaballero

I execute yours and it seems to works fine

Well, there's some blur at the the right and bottom borders that dissapears after a while. Do you mean this? How did you do the double buffer and cleaning it?

jj2007

Quote from: caballero on May 29, 2017, 02:28:34 AMWell, there's some blur at the the right and bottom borders that dissapears after a while.

Yes, but that's a different phenomenon. The blur comes from using \Masm32\MasmBasic\Res\MbBackground.gif as a background image, i.e. for "cleaning"; this is a 1 pixel image, and apparently when stretching to full size, Gdi+ plays little smoothing games :(

The outcome looks different with a "bigger" background, like the attached beach.jpg; unfortunately, this makes also come out the little defects in the tweety gif. Pretty odd behaviour.

Another solution is a GuiCls in the paint handler (which just paints the default main window background). See the difference in attachment. Note all three exes check the folder for all kind of images, you can scroll through them with the left and right keys (and rotate them with R and L, but that's irrelevant here).

avcaballero

I create a double buffering in memGraphics and clean it with GdipGraphicsClear.

jj2007

GdipGraphicsClear sounds like a good idea. May I steal it from you?  ;)

avcaballero