faster saveimage 8bit on OS X
faster saveimage 8bit on OS X
On my MacBook Air with SSD drive, 32bit and 4bit save within a second. But 8bit takes a few seconds. I haven't done any testing on XP or Linux to see if this is also true.
www.posemotion.com
PureBasic Tools for OS X: PureMonitor, plist Tool, Data Maker & App Chef
Even the vine knows it surroundings but the man with eyes does not.
PureBasic Tools for OS X: PureMonitor, plist Tool, Data Maker & App Chef
Even the vine knows it surroundings but the man with eyes does not.
Re: faster saveimage 8bit on OS X
What file format are you using ?
Re: faster saveimage 8bit on OS X
PNG format. I also began to wonder if it was due to the fact that converting a 32bit png to a 8bit png might be slower then 4bits because there is 256 colors instead of 16 to convert to? Could this be possible?wilbert wrote:What file format are you using ?
www.posemotion.com
PureBasic Tools for OS X: PureMonitor, plist Tool, Data Maker & App Chef
Even the vine knows it surroundings but the man with eyes does not.
PureBasic Tools for OS X: PureMonitor, plist Tool, Data Maker & App Chef
Even the vine knows it surroundings but the man with eyes does not.
Re: faster saveimage 8bit on OS X
I'm not sure but I imagine it can be a reason.
It probably has to do with finding the best color palette when decreasing the color depth.
Any reason why you are using 8 bit ?
It probably has to do with finding the best color palette when decreasing the color depth.
Any reason why you are using 8 bit ?
Re: faster saveimage 8bit on OS X
I use it in my Sprite Monkey app. Because if you are going to make a retro style game and use less colors, it might as well be in a 8bit or 4bit image format. Much smaller file size.wilbert wrote:I'm not sure but I imagine it can be a reason.
It probably has to do with finding the best color palette when decreasing the color depth.
Any reason why you are using 8 bit ?

www.posemotion.com
PureBasic Tools for OS X: PureMonitor, plist Tool, Data Maker & App Chef
Even the vine knows it surroundings but the man with eyes does not.
PureBasic Tools for OS X: PureMonitor, plist Tool, Data Maker & App Chef
Even the vine knows it surroundings but the man with eyes does not.
Re: faster saveimage 8bit on OS X
I don't know how PureBasic handles things.
Maybe you could use api calls to speed things up.
Maybe you could use api calls to speed things up.
Re: faster saveimage 8bit on OS X
Yeah, I thought about that or just creating my own procedure using plot and point. Which I already use for removing the alpha from 32bit to convert to 8 and 4bit. That way I could have a true RGB(255, 0, 255) background for those formats and not have to worry about the alpha channel blending into the RGB(255, 0, 255) background.wilbert wrote:I don't know how PureBasic handles things.
Maybe you could use api calls to speed things up.
www.posemotion.com
PureBasic Tools for OS X: PureMonitor, plist Tool, Data Maker & App Chef
Even the vine knows it surroundings but the man with eyes does not.
PureBasic Tools for OS X: PureMonitor, plist Tool, Data Maker & App Chef
Even the vine knows it surroundings but the man with eyes does not.
Re: faster saveimage 8bit on OS X
You could try using QuickTime.
I experimented a bit with it but haven't gotten everything right. Maybe someone else can look at it.
What's great about QuickTime is that it supports a lot of image formats.
The example below creates a png file named 'test.png' on the desktop but it only works if the file doesn't exist yet.
I haven't figured out an easy way to create a file that overwrites an existing one.
I experimented a bit with it but haven't gotten everything right. Maybe someone else can look at it.
What's great about QuickTime is that it supports a lot of image formats.
The example below creates a png file named 'test.png' on the desktop but it only works if the file doesn't exist yet.
I haven't figured out an easy way to create a file that overwrites an existing one.
Code: Select all
#kFSCatInfoNone = 0
#kOnSystemDisk = $8000
#kDesktopFolderType = 'desk'
#GraphicsExporterComponentType = 'grex'
#kQTFileTypePNG = 'PNGf'
#k4IndexedPixelFormat = 4
#k8IndexedPixelFormat = 8
ImportC ""
FSFindFolder(vRefNum, folderType, createFolder, *foundRef)
FSCreateFileUnicode(*parentRef, nameLength, name.p-unicode, whichInfo, *catalogInfo, *newRef, newSpec)
EndImport
ImportC "/System/Library/Frameworks/QuickTime.framework/QuickTime"
OpenADefaultComponent(componentType, componentSubType, *ci)
GraphicsExportSetInputCGImage(ci, imageRef)
GraphicsExportSetDepth(ci, depth)
GraphicsExportSetOutputFile(ci, *theFile)
GraphicsExportDoExport(ci, *actualSizeWritten)
CloseComponent(ci)
EndImport
CreateImage(0, 200, 200)
ImgRef = ImageID(0)
OpenADefaultComponent(#GraphicsExporterComponentType, #kQTFileTypePNG, @ci); export to png
GraphicsExportSetInputCGImage(ci, ImgRef); set input image
GraphicsExportSetDepth(ci, #k8IndexedPixelFormat); 8 bit
FSFindFolder(#kOnSystemDisk, #kDesktopFolderType, 0, @parentDir); find desktop folder
FSCreateFileUnicode(@parentDir, 8, "test.png", #kFSCatInfoNone, #Null, #Null, @fileSpec); create 'test.png' file on desktop
GraphicsExportSetOutputFile(ci, @fileSpec); set the file to export the image to
GraphicsExportDoExport(ci, #Null); export the image
CloseComponent(ci)
Re: faster saveimage 8bit on OS X
WOW, thanks wilbert! With PB I could easily check if the file exist and if it does, delete before writing the new one. I'll check this out more after I get some sleep. Thanks again! 

www.posemotion.com
PureBasic Tools for OS X: PureMonitor, plist Tool, Data Maker & App Chef
Even the vine knows it surroundings but the man with eyes does not.
PureBasic Tools for OS X: PureMonitor, plist Tool, Data Maker & App Chef
Even the vine knows it surroundings but the man with eyes does not.
Re: faster saveimage 8bit on OS X
I hope it works for you.
GIF or TIFF export is also possible using the QuickTime functions.
Here's some information about the QuickTime functions for Import / Export.
http://developer.apple.com/library/mac/ ... rence.html
I found out how to delete the file if it already exists.
Here's a more complete example
GIF or TIFF export is also possible using the QuickTime functions.
Here's some information about the QuickTime functions for Import / Export.
http://developer.apple.com/library/mac/ ... rence.html
I found out how to delete the file if it already exists.
Here's a more complete example
Code: Select all
#kFSCatInfoNone = 0
#kOnSystemDisk = $8000
#kDesktopFolderType = 'desk'
#kTextEncodingUnknown = $ffff
#GraphicsExporterComponentType = 'grex'
#kQTFileTypePNG = 'PNGf'
#kQTFileTypeTIFF = 'TIFF'
#kQTFileTypeBMP = 'BMPf'
#kQTFileTypeJPEG = 'JPEG'
#kQTFileTypeTargaImage = 'TPIC'
#k4IndexedPixelFormat = 4
#k8IndexedPixelFormat = 8
ImportC ""
FSFindFolder(vRefNum, folderType, createFolder, *foundRef)
FSMakeFSRefUnicode(*parentRef, nameLength, name.p-unicode, textEncodingHint, *newRef)
FSDeleteObject(*ref)
FSCreateFileUnicode(*parentRef, nameLength, name.p-unicode, whichInfo, *catalogInfo, *newRef, newSpec)
EndImport
ImportC "/System/Library/Frameworks/QuickTime.framework/QuickTime"
OpenADefaultComponent(componentType, componentSubType, *ci)
GraphicsExportSetInputCGImage(ci, imageRef)
GraphicsExportSetDepth(ci, depth)
GraphicsExportSetOutputFile(ci, *theFile)
GraphicsExportSetOutputHandle(ci, handle)
GraphicsExportDoExport(ci, *actualSizeWritten)
CloseComponent(ci)
EndImport
Procedure QTSaveImage(ImageID, FileName.s)
Global parentDir, fileSpec; don't know why but function crashes when there are not global
OpenADefaultComponent(#GraphicsExporterComponentType, #kQTFileTypePNG, @ci); export to png
GraphicsExportSetInputCGImage(ci, ImageID); set input image
GraphicsExportSetDepth(ci, #k8IndexedPixelFormat); 8 bit
FSFindFolder(#kOnSystemDisk, #kDesktopFolderType, 0, @parentDir); find desktop folder
FSMakeFSRefUnicode(@parentDir, Len(Filename), Filename, #kTextEncodingUnknown, @fileSpec); find existing file
If fileSpec : FSDeleteObject(@fileSpec) : EndIf; delete file if it exists
FSFindFolder(#kOnSystemDisk, #kDesktopFolderType, 0, @parentDir); find desktop folder
FSCreateFileUnicode(@parentDir, Len(FileName), Filename, #kFSCatInfoNone, #Null, #Null, @fileSpec); create new 'test.png' file on desktop
GraphicsExportSetOutputFile(ci, @fileSpec); set the file to export the image to
GraphicsExportDoExport(ci, #Null); export the image
CloseComponent(ci)
EndProcedure
If OpenWindow(0, 0, 0, 200, 200, "QT 2DDrawing Example", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
If CreateImage(0, 200, 200) And StartDrawing(ImageOutput(0))
y = 0
For x = 0 To 95 Step 10
Box(x, y, 200-2*x, 200-2*y, RGB(Random(255), Random(255), Random(255)))
y + 10
Next x
StopDrawing()
ImageGadget(0, 0, 0, 200, 200, ImageID(0))
EndIf
QTSaveImage(ImageID(0), "test.png"); save test.png to desktop
Repeat
Event = WaitWindowEvent()
Until Event = #PB_Event_CloseWindow
EndIf