Page 1 of 2

Animated GIF with transparency

Posted: Mon Jan 02, 2017 7:36 pm
by rdonnay
I'm looking for an OCX that can play animated GIF files that have transparency.

Does anyone have a suggestion?

Re: Animated GIF with transparency

Posted: Mon Jan 02, 2017 9:38 pm
by Auge_Ohr
what about using XbpHTMLViewer() to show animated GIF ?

Re: Animated GIF with transparency

Posted: Tue Jan 03, 2017 8:09 am
by rdonnay
what about using XbpHTMLViewer() to show animated GIF ?
I tried that and it isn't going to work.

We need the background transparency because we are overlaying an animated GIF over a bitmap.

XbpHTMLViewer paints a box with scroll bars.

Re: Animated GIF with transparency

Posted: Wed Jan 04, 2017 6:22 pm
by patito
Hi Roger

http://www.imagemagick.org/script/binary-releases.php

ImageMagick-7.0.4-2-Q16-x64-dll.exe
Use ImageMagick® to create, edit, compose, or convert bitmap images. It can read and write images in a variety of formats (over 200) including PNG, JPEG, JPEG-2000, GIF, TIFF, DPX, EXR, WebP, Postscript, PDF, and SVG. Use ImageMagick to resize, flip, mirror, rotate, distort, shear and transform images, adjust image colors, apply various special effects, or draw text, lines, polygons, ellipses and Bézier curves.
Here are just a few examples of what ImageMagick can do for you:


Animation create a GIF animation sequence from a group of images.
http://www.imagemagick.org/Usage/anim_basics/


http://www.imagemagick.org/Usage/anim_b ... grass2.gif

Best Regard
Hector

Re: Animated GIF with transparency

Posted: Wed Jan 04, 2017 6:55 pm
by rdonnay
Hector -

Thank you for that info.

I had already created my own Animation from a set of .PNG images.
I save all the image buffers into an XML file and then load the XML tree and step thru the tree to paint each image.

It works very good.

I'm going to post the sample here after a few finishing touches.

This is the code that creates the XML file with all the images:

Code: Select all

FUNCTION DC_AnimatedImageCreate( cPrefix, cType, aTransparentColor )

LOCAL aDir, cFileName, oBitmap, oAnimate, oImages, oImage, cImageFile, ;
      cBuffer, i

DEFAULT cPrefix := '', ;
        cType := 'BMP', ;
        aTransparentColor := { 192,192,192 }

aDir := Directory( cPrefix + '*.' + cType )

ASort( aDir,,,{|a,b|a[1]<b[1]})

IF Empty( aDir )

  DCMSGBOX 'Image File could not be created'

ELSE

  oAnimate := DC_XmlNode():new('AnimatedImage')
  oAnimate:addNode( DC_XmlNode():new('ImageFormat',Upper(cType)) )
  oAnimate:addNode( DC_XmlNode():new('TransparentColor',DC_ArrayString(aTransparentColor)) )
  oImages := DC_XmlNode():new('Images')
  oAnimate:addNode(oImages)

  oBitmap := XbpBitmap():new():create()
  cFileName := cPrefix + '.Xml'
  FOR i := 1 TO Len(aDir)
    cImageFile := aDir[i,1]
    oBitmap:loadFile(cImageFile)
    cBuffer := oBitmap:setBuffer()
    oImage := DC_XmlNode():new('Image')
    oImages:addNode(oImage)
    oImage:addNode( DC_XmlNode():new('FileName',cImageFile) )
    oImage:addNode( DC_XmlNode():new('EncodedData',Bin2Base64(cBuffer)) )
  NEXT

  oBitmap:destroy()

  oAnimate:writeXml(cFileName)

  DCMSGBOX 'File: ' + cFileName + ' was created.'

ENDIF

RETURN nil

Re: Animated GIF with transparency

Posted: Wed Jan 04, 2017 7:11 pm
by rdonnay
Here is an animation I created using the most current build of eXpress++ (265).

Build 265 will be released this month.

This sample requires Xbase++ 2.0, however it will also compile under 1.9 when build 265 is released.

http://bb.donnay-software.com/samples/animation.zip

Re: Animated GIF with transparency

Posted: Sat Jan 07, 2017 1:47 am
by Auge_Ohr
hi,

have run your Demo.

Comment

a.) load moving Bitmap (taxitest_ani00.jpg) with

Code: Select all

o:transparentClr := o:getDefaultBGColor()
b.) IMHO GraSaveScreen()/GraRestScreen() UDF is not need just

Code: Select all

oStatic:invalidateRect(aRect) // aRect := Size of moving Bitmap
c.) run it in a Thread
d.) use this Tip from Till

Code: Select all

/*
   Formdesiger Class Code

   \JHV2013\GUI-Anwendungen\Problems, Solutions\Flicker\Solution - ClipChildren\_TEST.PRG
*/

   ::XbpDialog:init( oParent, oOwner, aPos, aSize, aPP, lVisible )
   IF aSize[1] == 0 .AND. aSize[2] == 0
      ::XbpDialog:ClientSize := {582,359}
   ENDIF
   ::XbpDialog:drawingArea:clipChildren := .T.      // <- add THIS Line !!!
   ::XbpDialog:taskList := .T.
   ::XbpDialog:title := "New form"
have modify Alaska Sample \SOURCE\samples\basics\THREAD\Worms.prg.
Worm_transparent.jpg
Worm_transparent.jpg (107.71 KiB) Viewed 19714 times
WORMS.ZIP
EXE v1.9x, Source include
(690.1 KiB) Downloaded 845 times

Re: Animated GIF with transparency

Posted: Sat Jan 07, 2017 9:14 am
by rdonnay
o:transparentClr := o:getDefaultBGColor()
I can't believe I never saw this method before. That works just fine.
oStatic:invalidateRect(aRect) // aRect := Size of moving Bitmap
My first attempt at this used :invalidateRect() because that was so simple.
Unfortunately, it also causes too much flicker on large bitmaps.
This is why I had to develop a more complicated approach.
I needed a smoother animation. Since I posted my sample, I smoothed it out even more.
I also reduced the size of the .XML file by a factor of 10.
run it in a Thread
It IS running in a thread.
::XbpDialog:drawingArea:clipChildren := .T. // <- add THIS Line !!!
I still get the flicker when using invalidateRect().
I have replaced that with oBitmap:draw().

Here is an updated version:

http://bb.donnay-software.com/samples/animation.zip

Re: Animated GIF with transparency

Posted: Mon Jan 09, 2017 5:21 pm
by Auge_Ohr
rdonnay wrote:I still get the flicker when using invalidateRect().
I have replaced that with oBitmap:draw().
i need invalidateRect() to "activate" Ownerdraw ... :whistle:

i have made some Sample and try to "move" a smaller Image but it does flicker
when o:SetPos(aPos). same with o:SetCaption(x) when x = Bitmap.

i made a Class to "make" Bitmap using o:Draw.

Code: Select all

1.) using GraBitBlt() to "Snapshot" Parent Area ( o:FillBG() )
2.) xBanner:draw
3.) xPic:draw both to same Presspace
i can "save" it but i can't "see" it ... :evil:
so i try

Code: Select all

5.) make external Parent Ownerdraw
6.) now just oParent:invalidateRect() to activate Ownerdraw
and now i can "see" xBanner:Draw() without any flicker :dance:
YellowCab_transparent.jpg
YellowCab_transparent.jpg (96.2 KiB) Viewed 19667 times
YellowCab1.zip
Source, RES, XPJ
(687.63 KiB) Downloaded 853 times

Re: Animated GIF with transparency

Posted: Sat Feb 11, 2017 12:10 am
by Auge_Ohr
have found GIF89.DLL

have test it and made a small Demo and Help file
GIF98A.jpg
GIF98A.jpg (93.62 KiB) Viewed 19546 times
as you see it have only 2 Method : Play() and Stop()

as always you have to register GIF89.DLL as Administrator

Code: Select all

regsvr32.exe GIF89.DLL
have fun

! Note : on 64bit OS() you have to copy GIF89.DLL to C:\Windows\System32\ AND (!!!) c:\Windows\SysWOW64\ before register with c:\Windows\System32\regsvr32.exe