Would really appreciate help.
I've got a fair bit of this worked out but am stuck on something.

I am loading a Jpeg image from a file into an object of type TJPEGimage.
I then decompress it by Assigning the image to an object of type TBitmap.
The bitmap is contained by an Timage component.
I then write on the canvas altering a few pixels around.

If I then save this image as a bitmap, open it in a graphics program like
Corel Photo House, save it as a jpeg file (high quality compression), then
reopen it in my application the pixels I have tampered with have hardly
changed in colour.  (examining RGB values).

However if use the Delphi application to compress the bitmap back to a Jpeg
(Assigning the bitmap to a jpeg) - high quality compression, then save that
to file and reopen it, the colours of the pixels I have written on the
original jpeg image have changed quite substantially.  However the pixels on
other parts of the image that I have not touched have hardly changed, if at
all.

Can anyone suggest what I'm doing wrong?
Is it something to do with:
    the palette
    device dependent and independent bitmaps
    losing connection with the TJPEGdata object
    need to use .JPEGneeded?
    need to use TJPEGimage.compress?

These seem to be used in connection with Tstreams which I don't understand
yet.

The code I'm using:

OPENING AND DECOMPRESSING THE JPEG.

procedure TForm1.OpenButtonClick(Sender: TObject);
var
  CurrentFile: String;
  Jpeg:TJpegimage;
begin
  if OpenDialog1.Execute then
  begin
    CurrentFile := OpenDialog1.FileName;
    Jpeg:=TJpegimage.Create;
    Jpeg.Performance:=jpBestQuality;      //Quality Speed
    Jpeg.PixelFormat:=jf24bit;
    Jpeg.LoadFromFile(CurrentFile);

    image2.Picture.Bitmap.Assign(Jpeg);
 end;
end;

WRITING ON THE BITMAP

image2.Canvas.Pixels[X, Y]:=.......   etc as required over several 10's of
pixels.


COMPRESSING THE BITMAP BACK TO JPEG

procedure TForm1.BitBtn1Click(Sender: TObject);
var
  Jpeg2:TJpegimage;
begin

  Jpeg2:=TJpegimage.Create;
      Jpeg2.CompressionQuality:=100;
      Jpeg2.Assign(Image2.Picture.Bitmap);
      Jpeg2.SaveToFile('ee.jpg');
end;












---------------------------------------------------------------------------
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz

Reply via email to