Saving .PNG images in Linux
Posted: Sun Jun 03, 2018 1:35 pm
I've written a few simple apps that compile and run as expected on macOS and Windows but now I'm attempting to offer Linux versions as well.
There're a few things to sort out but a major problem at the moment centres around saving an image in .PNG format.
This same code works perfectly in macOS and Windows but, while it writes a .png file at the requested destination, Linux reckons "Fatal error reading PNG image file: Not a PNG file" when I try to view it.
Tested on Windows 7, 10, macOS High Sierra ... OK
Ubuntu 16.04 LTS, Mint 18 ... not so good.
Any ideas what I'm doing wrong?
TIA
Dave
There're a few things to sort out but a major problem at the moment centres around saving an image in .PNG format.
Code: Select all
Procedure imageSave(Image.l)
Define file$, PathPart$, FilePart$, buffer.l, w.i, h.i
file$ = SaveFileRequester("Save Image as PNG", "Image.png", "Images (.png)|*.png", 0)
If file$ > ""
w = GadgetWidth(Image)
h = GadgetHeight(Image)
PathPart$ = GetPathPart(file$)
FilePart$ = GetFilePart(file$, #PB_FileSystem_NoExtension)
file$ = PathPart$ + FilePart$ + ".png"
CreateImage(buffer, w, h)
StartDrawing(ImageOutput(buffer))
DrawImage(GetGadgetAttribute(Image, #PB_Canvas_Image), 0, 0)
FrontColor($0)
DrawingMode(#PB_2DDrawing_Outlined)
Box(0, 0, w, h)
StopDrawing()
SaveImage(buffer, file$)
FreeImage(buffer)
MessageRequester("Image:", "Saved as:" + #CR$ + file$)
EndIf
EndProcedure
Tested on Windows 7, 10, macOS High Sierra ... OK
Ubuntu 16.04 LTS, Mint 18 ... not so good.
Any ideas what I'm doing wrong?
TIA
Dave