• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 500
  • Last Modified:

Display an image pixel by pixel ( wipe FX )

I have a jpeg image and I wish to disply it with an wipe effect .
For example :
I need to display pixel by pixel first line . Then at last pixel of first line to display up to down last column of pixels .
At end of colomn to revers lighting of pixel from last pixel of last line to first pixel of same line and......

I wish to create a spirale ( circle ) display effect .
0
ginsonic
Asked:
ginsonic
  • 6
  • 4
1 Solution
 
TheNeilCommented:
Get your JPG into a TBitmap variable and then use the Pixels property of the canvas (TBitmap.Canvas.Pixels). This will be slow but you can then create a second TBitmap and copy across the pixels that you need in any way that you want.

To do a horizontal wipe (Assuming you have your JPG in a TBitmap called bmpOrig):

bmpTemp := TBitmap.Create;
bmpTemp.Assign(bmpOrig);
bmpTemp.Canvas.Brush.Color := clBlack;
bmpTemp.Canvas.FillRect(RECT(0,0,bmpTemp.Width, bmpTemp.Height));

FOR n := 0 TO (bmpOrig.Width - 1)
DO
BEGIN
  FOR m := 0 TO (bmpOrig.Height - 1)
  DO
    bmpTemp.Canvas.Pixels[n, m] := bmpOrig.Canvas.Pixels[n, m];
  Image1.Canvas.Draw(0, 0, bmpTemp);
END;
bmpTemp.Free;

This will create the second bitmap, copy each column of pixels across from the original image, and throw it at the screen (into Image1) when each column is copied. I know it would be quicker to copy the entire row of pixels in a single copy but this demonstrates the use of the pixel property. Of course doing everything in memory helps.

If you need the spiral effect then just modify the mapping from the original bitmap to the temporary bitmap so that it follows the pattern that you want (or ask)

The Neil
0
 
ginsonicAuthor Commented:
Hy Neil ,
I try your code but don't work .
Please, can you send me a project ?
My e-mail is nick@radioterra.ro

Regards,
Nick
0
 
ginsonicAuthor Commented:
Put an answer.
Thanks . It work .


I have a new question : How can I have an another Image in bmpTemp ?

I wish to display an image and then to wipe a second image over first .
To have an image , not a black background .
If you can help I will increase the points with another 100 .
Best regards,
Nick
0
Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

 
TheNeilCommented:
Ok, here's an answer (for the original question).

For the second question, just draw your first image onto bmpTemp rather than draw the black rectangle. The code will then wipe the new image over the top of it.

To make sure that it wipes properly (i.e. doesn't miss bits) make sure that the two images are the same size, and replace the lines

bmpTemp.Canvas.Brush.Color := clBlack;
bmpTemp.Canvas.FillRect(RECT(0,0,bmpTemp.Width, bmpTemp.Height));

with this:

bmpTemp.Canvas.Draw(0, 0, bmpNew_Image);

You just have to make sure that the second image is stored in bmpNew_Image

If the images AREN'T the same size then there are several things to do but I'll go into that only if you need it.

The Neil
0
 
ginsonicAuthor Commented:
Thanks!
0
 
ginsonicAuthor Commented:
Neil ,
Have you received my 200 points ?
Please send a mail to aknowledge me .
Nick
0
 
TheNeilCommented:
Ginsonic,

Yeah I got the points. Thanx

The Neil
0
 
ginsonicAuthor Commented:
Hy Neil . Sorry , I lose your email address .
I test your code with jpeg file ( not bmps ) and don't work . I try to modify the codes but don't work . I'm not very good in D :(

Help me and I will put a new question for you  ( FOR NEIL title ) with another 100 points .
0
 
TheNeilCommented:
No problem Nick (neils@minorplanet.com if you need it).

The solution was for BMPs as Delphi can't manipulate JPGs itself. What we need to do is get the code to load a JPG end convert it to a BMP - easy.

PROCEDURE JPG2BMP(Filename : STRING);
VAR
  JPEG : TJPegImage;
  BMP  : TBitmap;
BEGIN
  JPEG := TJPegImage.Create;
  BMP := TBitmap.Create;

  JPEG.LoadFromFile(Filename);
  BMP.Assign(JPEG);
  JPEG.Free;

//Image can now be used from here until the bitmap is destroyed

  BMP.Free;
END;

MAKE SURE THAT YOU HAVE THE JPEG UNIT IN YOUR USES SECTION (it's called Jpeg).

The JPG is then copied into your BMP (after the Assign) and you can use it as before.

Any problems, just ask

The Neil
0
 
ginsonicAuthor Commented:
I make a question for you . Look for 'For The Neil'.
I will test the code in today and I hope to give the points tonight .
CYA
0

Featured Post

Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

  • 6
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now