Recent

Author Topic: animation with picture in the background  (Read 20427 times)

Blue1987

  • Full Member
  • ***
  • Posts: 165
Re: animation with picture in the background
« Reply #15 on: April 12, 2011, 11:34:56 am »
maybe the background isn't transparent, to set bitmap transparency:

Code: [Select]
var
  tempbmp: TBitmap;
begin
  // Create Bitmap
  tempbmp:= TBitmap.Create;
  tempbmp.Width:= paintbox1.width;
  tempbmp.height:= paintbox1.height;

  // Set Transparent Color
  tempbmp.Transparent:=True;
  tempbmp.TransparentColor:=clFuchsia;

  // Fill Transparent Color
  tempbmp.Canvas.Pen.Color:=clFuchsia;
  tempbmp.Canvas.Brush.Color:=clFuchsia;
  tempbmp.Canvas.Rectangle(0,0,tempbmp.Width,tempbmp.Height);

  { Drawing code here }

  // Draw in PaintBox
  paintbox1.Canvas.Draw(0,0,tempbmp);

  // Free Memory
  tempbmp.Free;
end;     



thank you... now the problem is that it doesn't clear the previous draw... buy I think I will solve it using two image (one with transparency on)


by the way... is there any simple way to load a jpeg file into a tbitmap?

Blue1987

  • Full Member
  • ***
  • Posts: 165
Re: animation with picture in the background
« Reply #16 on: April 12, 2011, 12:13:57 pm »
hey.. there's something which doesn't work!!

I created another image (say "sfondo", which is in the background) with the picture I want in the background. then...
I am drawing the graph first in tempbmp and then copying it to grafico2 (as you showed me)

- if I only set grafico2.transparent := true, it leave me with the black background without making it transparent.
- if I set grafico2.picture.bitmap := whatevercolor, it leave me with the whole grafico2 transparent (I mean, as it was hidden!!!)

lainz

  • Guest
Re: animation with picture in the background
« Reply #17 on: April 12, 2011, 02:37:41 pm »
hey.. there's something which doesn't work!!

I created another image (say "sfondo", which is in the background) with the picture I want in the background. then...
I am drawing the graph first in tempbmp and then copying it to grafico2 (as you showed me)

- if I only set grafico2.transparent := true, it leave me with the black background without making it transparent.
- if I set grafico2.picture.bitmap := whatevercolor, it leave me with the whole grafico2 transparent (I mean, as it was hidden!!!)

See the wiki:
http://wiki.lazarus.freepascal.org/Developing_with_Graphics

If you want use BGRABitmap:

*Alpha channel and comes with anti-aliased edges, filters..
*Setting alpha background is easy than TransparentColor ;)
*You can draw directly in TBGRABitmap, and then merge Picture with your Drawings easy.

Read the tutorial:
http://wiki.lazarus.freepascal.org/BGRABitmap_tutorial

Sample Graphics created with BGRABitmap:
http://wiki.lazarus.freepascal.org/Sample_Graphics

Blue1987

  • Full Member
  • ***
  • Posts: 165
Re: animation with picture in the background
« Reply #18 on: April 12, 2011, 05:12:11 pm »
See the wiki:
http://wiki.lazarus.freepascal.org/Developing_with_Graphics

If you want use BGRABitmap:

*Alpha channel and comes with anti-aliased edges, filters..
*Setting alpha background is easy than TransparentColor ;)
*You can draw directly in TBGRABitmap, and then merge Picture with your Drawings easy.

Read the tutorial:
http://wiki.lazarus.freepascal.org/BGRABitmap_tutorial

Sample Graphics created with BGRABitmap:
http://wiki.lazarus.freepascal.org/Sample_Graphics

i'll take a look... (since I see that it can be useful also for other graphical improvements...)
by the way, I simply do not understand why what I was doing wrong, and why it doesn't work.
(i just wanted to do something which I think it's kind of stupid! hence I cannot understand what's wrong in my code, and why I should change to a new library... it's a bit frustrating!)
« Last Edit: April 12, 2011, 05:40:55 pm by Blue1987 »

 

TinyPortal © 2005-2018