Forum > BGRABitmap and LazPaint
BGRABitmap - Certain Images don't load
bembulak:
Hi All!
As now solved here http://www.lazarus.freepascal.org/index.php/topic,14738.0.html my program works quite well.
Now I got stuck with the image loading routine. I have to load Paintings and Photos different sizes and file formats. Most of them (over 90% and therefore my main target) is JPG and PNG.
On some images it works perfect, on others it does nothing. At the moment I don't see any structure, why the loading fails.
Here's what I do, when loading the images:
--- Code: ---procedure ThwndMain.tbbLoadImageClick(Sender: TObject);
begin
openImageDlg.FileName := '';
recB := rect(0, 0, 0, 0);
if openImageDlg.Execute then
begin
if fileExists(openImageDlg.FileName) then
begin
try
rectList.Clear();
orig.LoadFromFile(openImageDlg.FileName);
recim.LoadFromFile(openImageDlg.Filename);
DrawingArea.Width := orig.Width;
DrawingArea.Height := orig.Height;
with recim do
begin
with bitmap do
begin
Canvas.Pen.Color := clRed;
Canvas.Pen.Width := 3;
Canvas.Pen.Style := psDash;
Canvas.Brush.Style := bsClear;
end;
end;
orig.Draw(DrawingArea.Canvas, 0, 0, True);
DrawingArea.Enabled := True;
except
on E: Exception do
ShowMessage(E.ClassName + ' ' + E.Message);
end; // end try
end; // end file.exists.
end // end open Image dialog
else
begin
ShowMessage('File does not exist???');
end;
end;
--- End code ---
The program does not come up with a message box, nor an exception. It just doesn't load certain images.
No matter if it's JPG or PNG big or small - sometimes nothing happens at all.
If it helps: my system language is German, so I use "Umlauts" in some filenames/paths.
Any help or hint is highly appreciated. Thanks for reading!
lainz:
you must use FileExistsUTF8
and you can load recim from orig instead loading twice from file.
bembulak:
--- Quote ---you must use FileExistsUTF8
--- End quote ---
Thanks.
Done that and I can load images from such a path now, however I get a debugger error + Exception now:
Debugger says: File "E:\Daten\öää\test.png" does not exist
and the Exception.Message is: FPImageException Error while reading stream: File "E:\Daten\öää\test.png" does not exist
circular:
What about using LoadFromFile(UTF8ToAnsi(openImageDlg.FileName)); ?
bembulak:
--- Quote from: cirular ---What about using LoadFromFile(UTF8ToAnsi(openImageDlg.FileName)); ?
--- End quote ---
It really seems to work now. Now I can go on ...
Thank you both very much for the help!
Navigation
[0] Message Index
[#] Next page