Animated GIF with transparency

This forum is for general support of Xbase++
Message
Author
User avatar
rdonnay
Site Admin
Posts: 4722
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Animated GIF with transparency

#1 Post by rdonnay »

I'm looking for an OCX that can play animated GIF files that have transparency.

Does anyone have a suggestion?
The eXpress train is coming - and it has more cars.

User avatar
Auge_Ohr
Posts: 1405
Joined: Wed Feb 24, 2010 3:44 pm

Re: Animated GIF with transparency

#2 Post by Auge_Ohr »

what about using XbpHTMLViewer() to show animated GIF ?
greetings by OHR
Jimmy

User avatar
rdonnay
Site Admin
Posts: 4722
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: Animated GIF with transparency

#3 Post 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.
The eXpress train is coming - and it has more cars.

patito
Posts: 121
Joined: Tue Aug 31, 2010 9:01 pm

Re: Animated GIF with transparency

#4 Post 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

User avatar
rdonnay
Site Admin
Posts: 4722
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: Animated GIF with transparency

#5 Post 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
The eXpress train is coming - and it has more cars.

User avatar
rdonnay
Site Admin
Posts: 4722
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: Animated GIF with transparency

#6 Post 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
The eXpress train is coming - and it has more cars.

User avatar
Auge_Ohr
Posts: 1405
Joined: Wed Feb 24, 2010 3:44 pm

Re: Animated GIF with transparency

#7 Post 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 19574 times
WORMS.ZIP
EXE v1.9x, Source include
(690.1 KiB) Downloaded 832 times
greetings by OHR
Jimmy

User avatar
rdonnay
Site Admin
Posts: 4722
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: Animated GIF with transparency

#8 Post 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
The eXpress train is coming - and it has more cars.

User avatar
Auge_Ohr
Posts: 1405
Joined: Wed Feb 24, 2010 3:44 pm

Re: Animated GIF with transparency

#9 Post 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 19527 times
YellowCab1.zip
Source, RES, XPJ
(687.63 KiB) Downloaded 833 times
greetings by OHR
Jimmy

User avatar
Auge_Ohr
Posts: 1405
Joined: Wed Feb 24, 2010 3:44 pm

Re: Animated GIF with transparency

#10 Post 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 19406 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
Attachments
XB_GIF89.ZIP
DLL / Xbase++ Demo Source
(71.89 KiB) Downloaded 836 times
greetings by OHR
Jimmy

Post Reply