Recent

Author Topic: wiley64 animated gif flicker  (Read 13861 times)

jw

  • Full Member
  • ***
  • Posts: 120
wiley64 animated gif flicker
« on: February 02, 2010, 11:13:19 pm »
when useing wiley64's animated gif control if one gif is displayed over top of the other it filckers back and forth like both controls are at war to be in front of the other.  I would like to know if there's a way to stop this and set one gif control behind the other, a zorder I think.  

I haven't tried vampyre gif apng yet if it will work then I'll use it.

« Last Edit: February 04, 2010, 11:00:57 pm by jw »

jw

  • Full Member
  • ***
  • Posts: 120
Re: wiley64 animated gif flicker
« Reply #1 on: February 04, 2010, 11:06:08 pm »
After messing with the gif control it seems that it doesn't have a transparent background setting.  I can choose a color but can't let it be transparent even when chooseing the clnone color.  I'm sure the gif it's loading is setup for background transparency as it works in other programs and in my vb code.

circular

  • Hero Member
  • *****
  • Posts: 3359
    • Personal webpage
Re: wiley64 animated gif flicker
« Reply #2 on: March 18, 2010, 05:17:45 pm »
If you want to avoid flicker, you need to draw both gif in a virtual screen, that is a bitmap which is not visible, and then draw the resulting bitmap on the screen.

Where can one download the component you are talking about ?
Conscience is the debugger of the mind

JD

  • Hero Member
  • *****
  • Posts: 1793
Re: wiley64 animated gif flicker
« Reply #3 on: March 18, 2010, 06:40:46 pm »
Where can one download the component you are talking about ?

http://wile64.perso.neuf.fr/download/download.php?cat=4

The site's in French but you should have no problems finding the components.
Windows (10, 7) - Lazarus 2.1/FPC 3.2, Delphi

Indy 10.6 series; mORMot; Zeos 7.3; SQLite, Firebird, PostgreSQL & MariaDB; VirtualTreeView 5.5.3 R1

jw

  • Full Member
  • ***
  • Posts: 120
Re: wiley64 animated gif flicker
« Reply #4 on: March 19, 2010, 05:02:55 pm »
thanks for looking but it's flickering when one sprite is position over the other because the gif library doesn't support transperency so there's the block background being drawn and that's what flickers.

circular

  • Hero Member
  • *****
  • Posts: 3359
    • Personal webpage
Re: wiley64 animated gif flicker
« Reply #5 on: March 20, 2010, 07:56:26 pm »
Ok. You can use the library i just wrote in order to avoid this. You can find it here.

You can use it this way :
Code: [Select]
uses AnimatedGif;

procedure TForm1.FormCreate(Sender: TObject);
begin
  gif := TAnimatedGif.Create('image.gif');
  rectgif := Rect(20,20,20+Gif.Width,20.Gif.Height);
end;

procedure TForm1.FormPaint(Sender: TObject);
begin
  Canvas.Draw(rectgif,gif);
end;   

procedure TForm1.Timer1Timer(Sender: TObject);
begin
  gif.Update(Canvas,rectgif);
end; 
« Last Edit: January 27, 2013, 04:18:51 pm by circular »
Conscience is the debugger of the mind

jw

  • Full Member
  • ***
  • Posts: 120
Re: wiley64 animated gif flicker
« Reply #6 on: March 21, 2010, 07:23:45 pm »
Wow I'm working on one of those library's but you beat me to it.  I'll check it out thanks....





circular

  • Hero Member
  • *****
  • Posts: 3359
    • Personal webpage
Re: wiley64 animated gif flicker
« Reply #7 on: March 24, 2010, 09:08:52 pm »
I am curious if it worked for you.
Conscience is the debugger of the mind

jw

  • Full Member
  • ***
  • Posts: 120
Re: wiley64 animated gif flicker
« Reply #8 on: January 02, 2011, 07:41:12 pm »
sorry for the loooooong wait on a reply, but it does work you've definitly made your point.  The control of animation from a timer allows me to have my zorder, and different background modes for the transparency is awesome.   But after much testing I'm haveing trouble actuallty animating the animated gif accross the screen without lot's of flicker.  I constructed a double buffer but it still flickers badly when moveing the image or I lose the transparency in the buffering and end up with a black background.

here's a cludge that does work, I buffer to a paintbox then copy from the paintbox canvas to a timage box.  The timage doesn't flicker when moveing, which I don't understand since a double buffer quick redraw to the paintbox after a move should have worked.



this is a nice enough animated gif library I'd like to make it a lazarus package for lazarus if possible like wile64's is.




Code: [Select]
unit fmain;

{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
  ExtCtrls, StdCtrls, AnimatedGif;

type

  { TForm1 }

  TForm1 = class(TForm)
    Button5: TButton;
    IdleTimer1: TIdleTimer;
    buffer: TPaintBox;
    panel1: TImage;

    procedure Button5Click(Sender: TObject);
    procedure FormActivate(Sender: TObject);
    procedure IdleTimer1Timer(Sender: TObject);

  private
    procedure AddImage();

  public
    { public declarations }

    //Buffer: TCustomBitmap;

    gif: record
               image: TAnimatedGif;
               r: TRect;
         end;


  end;

var
  Form1: TForm1;


implementation

{ TForm1 }

procedure TForm1.AddImage();
begin


     //Buffer:=TPortableNetworkGraphic.Create;

     // Buffer.Width:=buffer.Width;
     //Buffer.Height:=buffer.Height;



     with gif do
     begin
       image := TAnimatedGif.Create('monkey.gif');
       image.EraseColor := self.Color;

       r.top := 0;
       r.bottom := buffer.height;

       r.left := 0;
       r.right := buffer.width;



     end;

end;




procedure TForm1.FormActivate(Sender: TObject);
begin
     addimage;
end;



procedure TForm1.Button5Click(Sender: TObject);
begin


  panel1.left:=panel1.left+5;

  panel1.Canvas.CopyRect(Rect(0,0,buffer.Width,buffer.Height),
       buffer.Canvas,Rect(0,0,buffer.Width,buffer.Height));

end;





procedure TForm1.IdleTimer1Timer(Sender: TObject);
begin

   with gif do
   begin

       image.Update(buffer.Canvas,r);

   end;

    panel1.Canvas.CopyRect(Rect(0,0,buffer.Width,buffer.Height),
       buffer.Canvas,Rect(0,0,buffer.Width,buffer.Height));

end;




initialization
  {$I fmain.lrs}

end.
                                            
« Last Edit: January 02, 2011, 07:42:54 pm by jw »

circular

  • Hero Member
  • *****
  • Posts: 3359
    • Personal webpage
Re: wiley64 animated gif flicker
« Reply #9 on: February 06, 2011, 02:50:39 am »
sorry for the loooooong wait on a reply, but it does work you've definitly made your point.
Hello back.

Quote
The control of animation from a timer allows me to have my zorder, and different background modes for the transparency is awesome.
Cool.

Quote
But after much testing I'm haveing trouble actuallty animating the animated gif accross the screen without lot's of flicker.  I constructed a double buffer but it still flickers badly when moveing the image or I lose the transparency in the buffering and end up with a black background.

here's a cludge that does work, I buffer to a paintbox then copy from the paintbox canvas to a timage box.  The timage doesn't flicker when moveing, which I don't understand since a double buffer quick redraw to the paintbox after a move should have worked.
I am not sure I understand. Are you using a paintbox component for temporary drawing or are you using a virtual screen, a TBitmap where you do the drawing before copying it on a TImage ?

I you want to completely avoid flicker, each time you want to update, you must first clear the background, and then draw all gif in the right order with background mode gbmSimplePaint, and by using :
Code: [Select]
Canvas.StretchDraw(r, gifImage);
Quote
this is a nice enough animated gif library I'd like to make it a lazarus package for lazarus if possible like wile64's is.
Ok. There is some useless code in TMemBitmap. If it is only for drawing Gif, you can remove it (commentary, unused functions).
« Last Edit: February 06, 2011, 03:00:03 am by circular »
Conscience is the debugger of the mind

jw

  • Full Member
  • ***
  • Posts: 120
Re: wiley64 animated gif flicker
« Reply #10 on: February 06, 2011, 05:15:01 pm »
I worked a little at the gbmSimplePaint but could't overcome the flicker in the above code I used image.Update(buffer.Canvas,r);

I was buffering to a canvas then doing a copyrec to the timage to try and make a double buffer like the example code in the Lazarus c:\lazarus\examples\sprites.  But I lose the background transparency when I copy to a timage.  If I copy from the buffer to a paintbox the paitbox still flickers.

One other thing this code looks like it's pure pascal so will it work with osx amd and ppc versions since I rewrote the program to use vampire imageing library the program is no longer able to be compiler for ppc.
« Last Edit: February 06, 2011, 05:19:29 pm by jw »

circular

  • Hero Member
  • *****
  • Posts: 3359
    • Personal webpage
Re: wiley64 animated gif flicker
« Reply #11 on: February 06, 2011, 11:48:07 pm »
But I lose the background transparency when I copy to a timage.
How do you copy it ? With a Canvas.Draw or with Bitmap.Assign ? I guess the only way is to use Bitmap.Assign.

Do you want to have something behind the gif images or a single color is ok ?

If this is the case, you can first do a FillRect on the virtual screen, then Draw the gif images, and at the end assign it to the TImage.

Quote
One other thing this code looks like it's pure pascal so will it work with osx amd and ppc versions since I rewrote the program to use vampire imageing library the program is no longer able to be compiler for ppc.
I'm not sure I understand. I only tested it on Windows and Linux with Gtk. Anything else I can't tell. It uses standard functions so it should work, but it's not guaranteed at all.
Conscience is the debugger of the mind

 

TinyPortal © 2005-2018