Just trying to load a TPicture to put into a Timage on the screen, and getting an External: Access Violation. I don't know why. I put the picture (tried JPG and PNG formats - didn't make a difference). If I put in a non-existent file name, it gives a different error. Checked the properties of the file, seems to alright, and I can access the file with other programs, so I don't think it's a real problem. The code it points to, picture.inc line 688 is the only line in this routine:
procedure TPicture.LoadFromStreamWithFileExt(Stream: TStream;
const FileExt: string);
begin
LoadFromStreamWithClass(Stream, FindGraphicClassWithFileExt(FileExt));
end;
My unit looks like this:
unit Unit1;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ExtCtrls;
type
{ TForm1 }
TForm1 = class(TForm)
Image1: TImage;
procedure init(Sender: TObject);
private
public
end;
var
Form1: TForm1;
MyImg: TPicture;
implementation
{$R *.lfm}
{ TForm1 }
procedure TForm1.init(Sender: TObject);
var
CurrentDir: String;
Filename: String;
begin
//ProgramDir := ExtractFileDir(ParamStr(0));
//ShowMessage(ProgramDir);
CurrentDir := GetCurrentDir;
ShowMessage(CurrentDir);
Filename := CurrentDir + '\Blank.jpg';
MyImg.Create;
MyImg.LoadFromFile(Filename);
Image1.Picture:= MyImg;
Image1.Repaint;
end;
end.
Thanks for any help!
Tom A.
"Since the only way to reach the Sky Mountain was by air, the native prohibition against airships made no sense." - The
InUncredible Adventures of Baron Karnath