Skip to content

Commit d8a84e5

Browse files
author
MaximDude
committed
Save as Indexed Bitmap fully functional
Sped up indexed file saving by grabbing a smaller pixmap Fixed typo
1 parent 33a5197 commit d8a84e5

File tree

1 file changed

+27
-12
lines changed

1 file changed

+27
-12
lines changed

cccp-bender-main.bmx

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -156,20 +156,23 @@ EndRem
156156
Global importedFile:String = Null
157157
Global exportedFile:String = Null
158158

159+
'File Filters
160+
Global fileFilters:String
161+
159162
Type TAppFileIO
160163
'Save Bools
164+
Global saveAsIndexed:Int = False
161165
Global prepForSave:Int = False
162166
Global rdyForSave:Int = False
163167
Global runOnce:Int = False
164-
'File Filters
165-
Global fileFilers:String = "Image Files:png,bmp,jpg"
168+
166169
'Output copy for saving
167170
Global tempOutputImage:TPixmap
168171

169172
'Load Source Image
170173
Function FLoadFile()
171174
Local oldImportedFile:String = importedFile
172-
importedFile = RequestFile("Select graphic file to open",fileFilers)
175+
importedFile = RequestFile("Select graphic file to open","Image Files:png,bmp,jpg")
173176
'Foolproofing
174177
If importedFile = Null Then
175178
importedFile = oldImportedFile
@@ -201,14 +204,17 @@ Type TAppFileIO
201204

202205
'Save Output Content To File
203206
Function FSaveFile()
204-
exportedFile = RequestFile("Save graphic output",fileFilers,True)
207+
exportedFile = RequestFile("Save graphic output",fileFilters,True)
205208
'Foolproofing
206209
If exportedFile = importedFile Then
207210
Notify("Cannot overwrite source image!",True)
208211
ElseIf exportedFile <> importedFile Then
209212
'Writing new file
210-
'SavePixmapPNG(tempOutputImage,exportedFile)
211-
TBitmapIndex.FPixmapToIndexedBitmap(tempOutputImage,exportedFile)
213+
If saveAsIndexed = True
214+
TBitmapIndex.FPixmapToIndexedBitmap(tempOutputImage,exportedFile)
215+
Else
216+
SavePixmapPNG(tempOutputImage,exportedFile)
217+
EndIf
212218
FRevertPrep()
213219
Else
214220
'On Cancel
@@ -221,9 +227,6 @@ Rem
221227
------- OUTPUT ELEMENTS -----------------------------------------------------------------------------------------------
222228
EndRem
223229

224-
'Output Window Title
225-
AppTitle = "CCCP Bender v"+appVersion+" - Output"
226-
227230
Type TAppOutput
228231
'Output Window
229232
Global outputWindow:TGraphics
@@ -387,7 +390,12 @@ Type TAppOutput
387390
Next
388391
SetRotation(0)
389392
'Output copy for saving
390-
TAppFileIO.tempOutputImage = GrabPixmap(0,96,768,384)
393+
If TAppFileIO.saveAsIndexed = True Then
394+
'If saving indexed grab a smaller pixmap to speed up indexing
395+
TAppFileIO.tempOutputImage = GrabPixmap(55,120,34*FRAMES,210)
396+
Else
397+
TAppFileIO.tempOutputImage = GrabPixmap(0,96,768,384)
398+
EndIf
391399
Flip(1)
392400
If TAppFileIO.prepForSave
393401
TAppFileIO.FPrepForSave()
@@ -562,12 +570,19 @@ While True
562570
TAppGUI.FAppUpdate()
563571
Else
564572
TAppOutput.FOutputUpdate()
573+
If ButtonState(TAppGUI.editSettingsIndexedCheckbox) = True Then
574+
fileFilters = "Image Files:bmp"
575+
TAppFileIO.saveAsIndexed = True
576+
Else
577+
fileFilters = "Image Files:png"
578+
TAppFileIO.saveAsIndexed = False
579+
EndIf
565580
EndIf
566581

567582
WaitEvent
568583
'Print CurrentEvent.ToString()
569584

570-
'Event Responses
585+
'Event Responses
571586
'In Main Window
572587
If Not TAppGUI.mainToEdit Then
573588
Select EventID()
@@ -584,7 +599,7 @@ While True
584599
Case EVENT_WINDOWCLOSE, EVENT_APPTERMINATE
585600
Exit
586601
EndSelect
587-
'In Editor Window
602+
'In Editor Window
588603
ElseIf TAppGUI.mainToEdit Then
589604
Select EventID()
590605
Case EVENT_APPRESUME

0 commit comments

Comments
 (0)