Solved

How to swap to images?

Posted on 2002-03-06
4
150 Views
Last Modified: 2010-04-05
Hi

Problem: How to swap images ?

Info: 1 form  with  3 Image components and 1 BitButton
      Procedure bellow swaps images and works OK
 
procedure TForm1.BitBtn1Click(Sender: TObject);
begin
  Image3.Picture.Bitmap := Image1.Picture.Bitmap;
  Image1.Picture.Bitmap := Image2.Picture.Bitmap;
  Image2.Picture.Bitmap := Image3.Picture.Bitmap;
end;

To Do: i need procedure which will be like this one bellow,
       btw: procedure is not working  
 
procedure TForm1.BitBtn1Click(Sender: TObject);
var
   imgTemp: TBitmap;
begin
  imgTemp := Image1.Picture.Bitmap;
  Image1.Picture.Bitmap := Image2.Picture.Bitmap;
  Image2.Picture.Bitmap := imgTemp;
end;


Please, can anyone help me !
0
Comment
Question by:nosleep
  • 3
4 Comments
 
LVL 27

Accepted Solution

by:
kretzschmar earned 77 total points
ID: 6844076
use assign instead and create your tmpimage, like

procedure TForm1.BitBtn1Click(Sender: TObject);
var
  imgTemp: TBitmap;
begin
 imgTmp := TBitmap.Create;
 try
   imgTemp.Assign(Image1.Picture.Bitmap);
   Image1.Picture.Bitmap.assign(Image2.Picture.Bitmap);
   Image2.Picture.Bitmap.assign(imgTemp);
 finally
   imgTmp.free
 end;
end;

meikl ;-)
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 6844079
hu, 10 points :-(
not seen before
0
 

Author Comment

by:nosleep
ID: 6844609
OK, 77 points  for kretzchmar if good comment
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 6844843
well, thats ok,
if my comment solves your problem,
then don't forget the grading

watch out for the button "accept answer" or similar
on the upper right of each comment

meikl ;-)
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

27 Experts available now in Live!

Get 1:1 Help Now