Link to home
Start Free TrialLog in
Avatar of ginsonic
ginsonicFlag for Romania

asked on

For The Neil

Are U online ?
ASKER CERTIFIED SOLUTION
Avatar of TheNeil
TheNeil

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ginsonic

ASKER

I don't test yet the code ( I'm still to work ) .
How can I know if the picture is jpeg or bmp to know how I will do the slide ?

P.S. I'm on-line . U are ?
If U are on-line too , maybe we will comunicate faster .
Avatar of TheNeil
TheNeil

Yeah I'm online and should be for about the next 4 hours.

You'll have to load the image in regardless of what format it is so what I'd do is this:

IF Pos('JPG', UpperCase(ExtractFileExt(sFilename)) <> 0
THEN
  LoadJPG(sFilename)
ELSE
  LoadBMP(sFilename);

Then just make sure that the LoadJPG and LoadBMP routines (which you'll have to write) load the image into the same TBitmap variable.

i.e. LoadJPG loads a JPG (using the code I gave you earlier) into a variable called bmpOrig_IMG and LoadBMP loads a BMP into the same variable

As per usual, anymore help needed just ask

The Neil
I make a component for this code ( see down of page ).
If I use bmps work perfect .
If use jpeg files I can see the image for PicFrom , but when I command Slide all images are gone
..
:(

........

TGNSlide = class(TGraphicControl)

private
    { Private declarations }
    FPicFrom:TPicture;
    FPicTo:TPicture;
    picT:TPicture;
    procedure PictureFrom(Pic:TPicture);
    procedure PictureTo(Pic:TPicture);

 public
    { Public declarations }
    procedure Slide;

 published
    { Published declarations }
    property PicFrom : TPicture read FPicFrom write PictureFrom;
    property PicTo : TPicture read FPicTo write PictureTo;

.........

procedure TGNSlide.Slide;
VAR
  bmpTemp : TPicture;
  n       : INTEGER;
  m       : INTEGER;

begin

  bmpTemp := TPicture.Create;
  bmpTemp.Assign(FPicTo);
  bmpTemp.Bitmap.Canvas.Draw(0, 0, FPicFrom.Bitmap);

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

end;
Hmmm. I'm not a big component expert so I'm not 100% certain as to why it doesn't want to work but I do have an idea. In your Slide routine, replace the TPicture with TBitmap. It could be something to do with the way the JPEG image is stored in the TPicture.

The Neil
It's work . Thanks .
i have a minir problem .
How can I refresh the PicFrom ?
How can I force the program to repaint the bitmap ?

Only if you can help me .
Thx again for help.
And hope to help me in future .
It's work . Thanks .
I have a minor problem .
How can I refresh the PicFrom ?
How can I force the program to repaint the bitmap ?

Only if you can help me .
Thx again for help.
And hope to help me in future .
Thanks again Neil .
Anytime Nick

The Neil
I fix my problem .
Just Refresh :)
See U,
Nick