 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
RSK Guest
|
Posted: Mon Jun 14, 2004 6:11 am Post subject: Flip bitmaps |
|
|
Hi,
Is there a rtl or api function to flip a bitmap image?
Thanks,
RSK.
|
|
| Back to top |
|
 |
Yannis Guest
|
Posted: Mon Jun 14, 2004 8:43 am Post subject: Re: Flip bitmaps |
|
|
Hi,
Here is my routine to do flipping using the windows strechdraw routine.
Hope this helps.
I have heard varius stories about failure of the below technik but I
haven't encounter any my self. It is said that because this technick
is using the stretch draw it is driver dependent which meens that in
some graphic cards it might not work as expected. I haven't seen any
problems until now but then again I'm using it internally only.
Type
TMirror = (mtHorizontal, mtVertical, mtBoth);
procedure Mirror(Picuter:Tpicture; MirrorType: TMirror);
var
MemBmp: Graphics.TBitmap;
Dest: TRect;
begin
if Assigned(Picture.Graphic) then
begin
MemBmp := Graphics.TBitmap.Create;
try
MemBmp.PixelFormat := pf24bit;
MemBmp.HandleType := bmDIB;
MemBmp.Width := Self.Picture.Graphic.Width;
MemBmp.Height := Self.Picture.Height;
MemBmp.Canvas.Draw(0, 0, Picture.Graphic);
case MirrorType of
mtHorizontal:
begin
//SpiegelnVertikal(MemBmp);
//SpiegelnHorizontal(MemBmp);
Dest.Left := MemBmp.Width;
Dest.Top := 0;
Dest.Right := -MemBmp.Width;
Dest.Bottom := MemBmp.Height;
end;
mtVertical:
begin
Dest.Left := 0;
Dest.Top := MemBmp.Height;
Dest.Right := MemBmp.Width;
Dest.Bottom := -MemBmp.Height;
end;
mtBoth:
begin
Dest.Left := MemBmp.Width;
Dest.Top := MemBmp.Height;
Dest.Right := -MemBmp.Width;
Dest.Bottom := -MemBmp.Height;
end;
end;
StretchBlt(MemBmp.Canvas.Handle, Dest.Left, Dest.Top, Dest.Right,
Dest.Bottom,
MemBmp.Canvas.Handle, 0, 0, MemBmp.Width,
MemBmp.Height, SRCCOPY);
Picture.Graphic.Assign(MemBmp);
Invalidate;
finally
FreeAndNil(MemBmp);
end;
end;
end;
Regards
Yannis.
"RSK" <Tecdiscuss (AT) Yahoo (DOT) com> wrote in
news:40cd418f (AT) newsgroups (DOT) borland.com:
| Quote: | Hi,
Is there a rtl or api function to flip a bitmap image?
Thanks,
RSK.
|
|
|
| Back to top |
|
 |
RSK Guest
|
Posted: Sun Jun 20, 2004 2:04 pm Post subject: Re: Flip bitmaps |
|
|
Hi Yannis,
Thank you for your help,
best regards,
RSK.
"Yannis" <None (AT) Noware (DOT) non> wrote
| Quote: | Hi,
Here is my routine to do flipping using the windows strechdraw routine.
Hope this helps.
I have heard varius stories about failure of the below technik but I
haven't encounter any my self. It is said that because this technick
is using the stretch draw it is driver dependent which meens that in
some graphic cards it might not work as expected. I haven't seen any
problems until now but then again I'm using it internally only.
Type
TMirror = (mtHorizontal, mtVertical, mtBoth);
procedure Mirror(Picuter:Tpicture; MirrorType: TMirror);
var
MemBmp: Graphics.TBitmap;
Dest: TRect;
begin
if Assigned(Picture.Graphic) then
begin
MemBmp := Graphics.TBitmap.Create;
try
MemBmp.PixelFormat := pf24bit;
MemBmp.HandleType := bmDIB;
MemBmp.Width := Self.Picture.Graphic.Width;
MemBmp.Height := Self.Picture.Height;
MemBmp.Canvas.Draw(0, 0, Picture.Graphic);
case MirrorType of
mtHorizontal:
begin
//SpiegelnVertikal(MemBmp);
//SpiegelnHorizontal(MemBmp);
Dest.Left := MemBmp.Width;
Dest.Top := 0;
Dest.Right := -MemBmp.Width;
Dest.Bottom := MemBmp.Height;
end;
mtVertical:
begin
Dest.Left := 0;
Dest.Top := MemBmp.Height;
Dest.Right := MemBmp.Width;
Dest.Bottom := -MemBmp.Height;
end;
mtBoth:
begin
Dest.Left := MemBmp.Width;
Dest.Top := MemBmp.Height;
Dest.Right := -MemBmp.Width;
Dest.Bottom := -MemBmp.Height;
end;
end;
StretchBlt(MemBmp.Canvas.Handle, Dest.Left, Dest.Top, Dest.Right,
Dest.Bottom,
MemBmp.Canvas.Handle, 0, 0, MemBmp.Width,
MemBmp.Height, SRCCOPY);
Picture.Graphic.Assign(MemBmp);
Invalidate;
finally
FreeAndNil(MemBmp);
end;
end;
end;
Regards
Yannis.
"RSK" <Tecdiscuss (AT) Yahoo (DOT) com> wrote in
news:40cd418f (AT) newsgroups (DOT) borland.com:
Hi,
Is there a rtl or api function to flip a bitmap image?
Thanks,
RSK.
|
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|