Forum > Operating Systems
problems loading file with crosscompiled code
CorBee:
Hi,
I am developing a freeware application that uses 16bit/channel PNG files to do some image-processing for amateur astronomers. Ive setup the code in Linux (FPC3.2.2) and it works fine. I can load files and access the data easily, processing works fine too.
The code to load the PNG into memory looks like this:
Procedure LoadImagetoMemory(filename:string);
var Ext:string;
begin
ext:=ExtractFileExt(filename);
if (ext='.png') then
begin
MemoryImage := TFPMemoryImage.Create(0,0);
MemoryImage.Loadfromfile(filename);
end;
end;
memoryimage is earlier declared as MemoryImage: TFPMemoryImage;
In a button Click procedure I have this code:
....
OpenPictureDialog1.Execute;
if (OpenPictureDialog1.Files.Count = 1) and (FileExists(OpenPictureDialog1.FileName)) then
begin
ScreenImage.Picture.LoadFromFile(OpenPictureDialog1.FileName);
LoadImageToMemory(OpenPictureDialog1.FileName);
end;
As stated this works perfectly on Linux but on windows the 1st call (screenimage.Picture.Loadfromfile(...)) does
work and the image gets displayed on screen. But the second call (loadImageToMemory) simply fails with a
"FILE NOT OPEN" error. Originally I did not have (since I do not need it) the call to screenimage.picture.loadfromfile but
I wanted to see if I could isolate the problem at least before asking for help. It looks as if the MemoryImage system after cross-compiling for windows does not work the same as in Linux.
I would like to hear how I can bypass this ? Ive also thought about using the BGRABitmap system, the TexpandedBitmap seems
a good candidate but I have not seen code that uses it for a 16bit PNG usecase like mine.
kind regards
Cor Berrevoets
*************************************************
RegiStax Free Image Processing Software
http://www.astronomie.be/registax
*************************************************
​TeensyBat Bat Detector
https://github.com/C...nsy_batdetector
KodeZwerg:
--- Quote from: CorBee on October 28, 2022, 05:22:07 pm --- OpenPictureDialog1.Execute;
if (OpenPictureDialog1.Files.Count = 1) and (FileExists(OpenPictureDialog1.FileName)) then
begin
ScreenImage.Picture.LoadFromFile(OpenPictureDialog1.FileName);
LoadImageToMemory(OpenPictureDialog1.FileName);
--- End quote ---
You can setup in options that the open dialog only returns file that exists, that way you can eliminate all your upgoing checks and write it like...
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---if OpenPictureDialog1.Execute then doSomething...
KodeZwerg:
--- Quote from: CorBee on October 28, 2022, 05:22:07 pm --- ScreenImage.Picture.LoadFromFile(OpenPictureDialog1.FileName);
--- End quote ---
At that point the image is already in memory... ?!
KodeZwerg:
--- Quote from: CorBee on October 28, 2022, 05:22:07 pm ---Procedure LoadImagetoMemory(filename:string);
var Ext:string;
begin
ext:=ExtractFileExt(filename);
if (ext='.png') then
begin
MemoryImage := TFPMemoryImage.Create(0,0);
MemoryImage.Loadfromfile(filename);
end;
end;
--- End quote ---
I do not know what TFPMemoryImage is, but you create here a memoryleak each time you call that method!
CorBee:
Hi,
Ive added the code to load a file through the picturedialog only to test things. The file gets loaded once in this setup only so a memoryleak is not a worry or the issue. The issue is that in windows loading in a memoryimage fails and in linux (with the same code) this works fine.
Thanks for having a look but the issue is not due to memoryleaks etc.
cheers
Cor
Navigation
[0] Message Index
[#] Next page