#1 Re: GDI+ » GIF, TIF, PNG and JPG pictures TGraphic read/write via GDI+ » 2012-06-25 09:23:13

Thanks for the heads up.  I undefined the compiler directive, re-ran, and now I have a successful result.

But I'm having an issue trying to get a JPG that is in a stream into a graphic.  I'm going to play some more before I whine about something else I didn't read about. {smirk}

Edit: Over thought things at this end.  All working as intended.  TYVM.

#2 Re: GDI+ » GIF, TIF, PNG and JPG pictures TGraphic read/write via GDI+ » 2012-06-24 03:52:00

I look forward to using these units!

I'm running Win7 Pro 64-bit, compiling under D7Pro 7.2.  I'm trying to use the LoadFromFile routine.  Tracing through your code, I get stopped at line 1200:

  if not Gdip.Exists or not FileExists(FileName) then
    exit;

Tracing through it looks through the function [Exists] returns, but then immediately jumps to the end of the LoadFromFile routine.  Doesn't even hit the EXIT command.

So I tried changing the logic of the code, JUST to make sure.

procedure TSynPicture.LoadFromFile(const FileName: string);
var FS: TFileStream;
begin // don't use direct GDI+ file oriented API: it's better having a local
  // copy of the untouched data in memory (e.g. for further jpeg saving)
  Clear;
  if (Gdip.Exists) then
    if (FileExists(FileName)) then begin
      FS := TFileStream.Create(FileName,fmOpenRead or fmShareDenyNone);
      try
        LoadFromStream(FS);
      finally
        FS.Free;
      end;
    end;

end;

So apparently GDIP actually doesn't exist?  It goes again through the function Exists, but then drops right to the end of the function.

What am I doing wrong?

Here is the code I'm using:

procedure TForm1.Button2Click(Sender: TObject);
var
  Pic:TSynPicture;

const fname='C:\Users\Stephen\Dropbox\Photos\Grand Am\DSC00824.jpg';

begin
  Pic:=TSynPicture.Create;
  Pic.LoadFromFile(fname);
  Image1.Picture.Graphic:=Pic;

  image2.Picture.LoadFromFile(fname);
end;

Image2 does render the image.

Board footer

Powered by FluxBB