News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests

Main Menu

Animated GIF viewer

Started by jj2007, November 20, 2016, 02:35:26 AM

Previous topic - Next topic

jj2007

This was actually easier than I thought - GdiPlus rocks :t

GuiTimerMs=100      ; more is slower
GuiParas equ "Simple GIF viewer", w240, h200
include \masm32\MasmBasic\Res\MbGui.asm      ; part of MasmBasic

SetGlobals DimensionIDs:GUID, frames, curFrame

Event Paint
  GuiImageCallback MyAnimate
  .if CL$(?)
      GuiImage CL$(), fit      ; drag an animated gif over the exe
  .else
      GuiImage 100, fit      ; or show tweetie from the resources
  .endif

EndOfEvents

MyAnimate:
  GuiCls                  ; force a refresh
  gdi+ GdipImageGetFrameDimensionsList, gicbObj, addr DimensionIDs, 1
  gdi+ GdipImageGetFrameCount, gicbObj, addr DimensionIDs, addr frames
  mov ecx, frames
  inc curFrame
  If_ curFrame>=ecx Then and curFrame, 0
  gdi+ GdipImageSelectActiveFrame, gicbObj, addr DimensionIDs, curFrame
retn

GuiEnd


Project attached - to build it (MasmBasic required), use your own GIF images, and adjust the Rsrc section accordingly. Note the viewer will show other types of images, if supplied via the commandline, but only GIF, PNG and TIFF can be animated formats afaik. The few animated PNG images don't work with this viewer :(

P.S. Try this from a DOS prompt: AnimatedGifViewer.exe https://www.clicktorelease.com/code/gif/1.gif (2...4.gif are nice, too)

Another one: AnimatedGifViewer.exe https://www.mathworks.com/matlabcentral/mlc-downloads/downloads/submissions/21944/versions/3/screenshot.gif

And one TIFF example: AnimatedGifViewer.exe http://www.nightprogrammer.org/wp-uploads/2013/02/multipage_tiff_example.tif

guga

Great work, JJ

i´ll take a look at this later :thumbsup: :thumbsup: :thumbsup:
Coding in Assembly requires a mix of:
80% of brain, passion, intuition, creativity
10% of programming skills
10% of alcoholic levels in your blood.

My Code Sites:
http://rosasm.freeforums.org
http://winasm.tripod.com

jj2007

Thanks, Guga. This is old stuff, though - in the meantime, I've simplified it a bit...

GuiParas equ "Animated GIF viewer", w900, h700, icon Star
include \masm32\MasmBasic\Res\MbGui.asm
GuiControl Canvas, "canvas"
Event CanvasPaint
  GuiImage wCL$(), fit
GuiEnd

guga

Quote from: jj2007 on October 15, 2020, 03:46:38 AM
Thanks, Guga. This is old stuff, though - in the meantime, I've simplified it a bit...

GuiParas equ "Animated GIF viewer", w900, h700, icon Star
include \masm32\MasmBasic\Res\MbGui.asm
GuiControl Canvas, "canvas"
Event CanvasPaint
  GuiImage wCL$(), fit
GuiEnd


Great work, but then i can´t see what is underneath. From the older code i saw you used

"  gdi+ GdipImageGetFrameDimensionsList, gicbObj, addr DimensionIDs, 1
  gdi+ GdipImageGetFrameCount, gicbObj, addr DimensionIDs, addr frames
  mov ecx, frames
  inc curFrame
  If_ curFrame>=ecx Then and curFrame, 0
  gdi+ GdipImageSelectActiveFrame, gicbObj, addr DimensionIDs, curFrame"

But, the new one..how it was created ?


Btw...Did you never considered creating a sort of "unfold macro" or a routine in masmbasic allowing to see the code being used underneath the macros/commands such as "GuiImage", "GuiControl" etc ? Altough i really like this form of simplicity, i fail to understand what Apis are involved behind those commands/macros.
Coding in Assembly requires a mix of:
80% of brain, passion, intuition, creativity
10% of programming skills
10% of alcoholic levels in your blood.

My Code Sites:
http://rosasm.freeforums.org
http://winasm.tripod.com

jj2007

At the bottom of the source (after EndOfCode), type syms<space>
Then insert an int 3 somewhere, e.g. below Event CanvasPaint. Make sure OllyDbg sits at \Masm32\OllyDbg\ollydbg.exe, and hit F6, then F9 in Olly; from then on, F8 until you reach ImgPaintP; continue with F7/F8 :cool:

(it's not allowed by the license, but I herewith grant an exception to you, Guga :cool:)

guga

Quote from: jj2007 on October 15, 2020, 05:25:04 AM
At the bottom of the source (after EndOfCode), type syms<space>
Then insert an int 3 somewhere, e.g. below Event CanvasPaint. Make sure OllyDbg sits at \Masm32\OllyDbg\ollydbg.exe, and hit F6, then F9 in Olly; from then on, F8 until you reach ImgPaintP; continue with F7/F8 :cool:

(it's not allowed by the license, but I herewith grant an exception to you, Guga :cool:)

WOW. Tks a lot, JJ  :thumbsup: :thumbsup: :thumbsup: :thumbsup: :thumbsup: :thumbsup:

I´ll take a look to see how it works. :)  It maybe useful for the resource editor to allow people actually loading and seeing animated gifs inserted as RC_DATA type on the resource sections of a PE.
Coding in Assembly requires a mix of:
80% of brain, passion, intuition, creativity
10% of programming skills
10% of alcoholic levels in your blood.

My Code Sites:
http://rosasm.freeforums.org
http://winasm.tripod.com

jj2007

Here is one using resources:

GuiParas equ "Animated GIF viewer", w900, h700, icon Ball
include \masm32\MasmBasic\Res\MbGui.asm
GuiImageSpeed 25, 2000         ; 25% speed, 2 seconds pause after each animation
GuiControl Canvas, "canvas"
Event CanvasPaint
  GuiImage 98, fit
  GuiImage 99, fit
GuiEnd

Resources must be put below GuiEnd; when pressing F6, content between the two Rsrc lines will be written to [filename].rc
ID 59 is reserved for the toolbar in GuiData.zip. Note opt_icon will be ignored - what counts is the icon specified in the resource file.
You may delete these three lines once you don't need them any more.
Rsrc
#include "resource.h"
01 RT_MANIFEST "\\Masm32\\MasmBasic\\Res\\XpManifest.xml"
98 RCDATA pics\\Clouds.jpg      ; background image
99 RCDATA pics\\Rockphorr.gif   ; the animation
Rsrc

guga

Quote from: jj2007 on October 15, 2020, 08:29:57 AM
Here is one using resources:

GuiParas equ "Animated GIF viewer", w900, h700, icon Ball
include \masm32\MasmBasic\Res\MbGui.asm
GuiImageSpeed 25, 2000         ; 25% speed, 2 seconds pause after each animation
GuiControl Canvas, "canvas"
Event CanvasPaint
  GuiImage 98, fit
  GuiImage 99, fit
GuiEnd

Resources must be put below GuiEnd; when pressing F6, content between the two Rsrc lines will be written to [filename].rc
ID 59 is reserved for the toolbar in GuiData.zip. Note opt_icon will be ignored - what counts is the icon specified in the resource file.
You may delete these three lines once you don't need them any more.
Rsrc
#include "resource.h"
01 RT_MANIFEST "\\Masm32\\MasmBasic\\Res\\XpManifest.xml"
98 RCDATA pics\\Clouds.jpg      ; background image
99 RCDATA pics\\Rockphorr.gif   ; the animation
Rsrc


Tks, JJ

Btw...do you know how to load , export and view icon files (multiple or single formats and also containing transparent background) using gdi plus ?

http://masm32.com/board/index.php?topic=8849.msg96584#msg96584
Coding in Assembly requires a mix of:
80% of brain, passion, intuition, creativity
10% of programming skills
10% of alcoholic levels in your blood.

My Code Sites:
http://rosasm.freeforums.org
http://winasm.tripod.com

Mikl__


jj2007

I know, Mikl - it was your thread that inspired me to write my version :thumbsup:

include \masm32\MasmBasic\Res\MbGui.asm
  GuiControl Canvas, "canvas"
Event CanvasPaint
  GuiImage uCL$()               ; drag any image file over the exe (Unicode is allowed)
GuiEnd
OPT_Arg1 pics\Твити.gif         ; for testing, ask RichMasm to add a commandline