Skip to content

Commit 035d98f

Browse files
committed
Get saving working again
1 parent 7f79410 commit 035d98f

File tree

4 files changed

+54
-25
lines changed

4 files changed

+54
-25
lines changed

Bender.bmx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,12 @@ Repeat
5555
g_GraphicsOutput.LoadFile(g_FileIO.SetFileToLoad())
5656
'Saving
5757
Case g_UserInterface.m_SaveButton
58-
g_GraphicsOutput.GrabOutputForSaving()
58+
If g_FileIO.GetSaveAsFrames() Then
59+
g_GraphicsOutput.RevertBackgroundColorAfterSave(g_FileIO.SaveFileAsFrames(g_GraphicsOutput.GrabOutputFramesForSaving(), g_GraphicsOutput.GetFrameCount()))
60+
Else
61+
g_GraphicsOutput.RevertBackgroundColorAfterSave(g_FileIO.SaveFile(g_GraphicsOutput.GrabOutputForSaving()))
62+
EndIf
63+
Continue
5964
'Scale
6065
Case g_UserInterface.m_SettingsZoomTextbox
6166
g_UserInterface.SetZoomTextboxValue(g_GraphicsOutput.SetInputZoom(g_UserInterface.GetZoomTextboxValue()))

types/FileIO.bmx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Import "IndexedImageWriter.bmx"
55

66
Type FileIO
77
Field m_ImportedFile:String = Null
8-
Field m_FileFilters:String
8+
Field m_FileFilters:String = "Image Files:png"
99

1010
Field m_SaveAsIndexed:Int = False
1111
Field m_SaveAsFrames:Int = False
@@ -38,6 +38,12 @@ Type FileIO
3838
Return m_ImportedFile
3939
EndMethod
4040

41+
'////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
42+
43+
Method GetSaveAsFrames:Int()
44+
Return m_SaveAsFrames
45+
EndMethod
46+
4147
'////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
4248

4349
Method SetSaveAsFrames:Int(framesOrNot:Int)

types/GraphicsOutput.bmx

Lines changed: 40 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,12 @@ Type GraphicsOutput
6363
Return m_InputZoom
6464
EndMethod
6565

66+
'////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
67+
68+
Method GetFrameCount:Int()
69+
Return m_FrameCount
70+
EndMethod
71+
6672
'////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
6773

6874
Method SetFrameCount:Int(newCount:Int)
@@ -76,6 +82,14 @@ Type GraphicsOutput
7682
SetClsColor(rgbValue[0], rgbValue[1], rgbValue[2])
7783
EndMethod
7884

85+
'////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
86+
87+
Method RevertBackgroundColorAfterSave(revertOrNot:Int)
88+
If revertOrNot Then
89+
ChangeBackgroundColor(m_BackgroundColor)
90+
EndIf
91+
EndMethod
92+
7993
'////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
8094

8195
Method SetDrawOutputFrameBounds(drawOrNot:Int)
@@ -92,7 +106,6 @@ Type GraphicsOutput
92106
m_LimbManager.SetJointMarker(mousePos)
93107
EndIf
94108
EndIf
95-
ChangeBackgroundColor(m_BackgroundColor)
96109
EndMethod
97110

98111
'////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -136,36 +149,40 @@ Type GraphicsOutput
136149

137150
'////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
138151

139-
Method GrabOutputForSaving()
140-
Rem
141-
152+
Method GrabOutputForSaving:TPixmap()
142153
If m_SourceImage = Null Then
143154
Notify("Nothing to save!", False)
144155
Else
145156
ChangeBackgroundColor(c_Magenta)
146157
Draw()
158+
Flip(1) 'Have to flip again for background color to actually change, not sure why but whatever
159+
Return GrabPixmap(55, 120, 34 * m_FrameCount, 210)
160+
EndIf
161+
EndMethod
147162

148-
If Not g_FileIO.m_SaveAsFrames Then
149-
g_FileIO.SaveFile(GrabPixmap(55, 120, 34 * m_FrameCount, 210))
150-
Else
151-
Local framesToSave:TPixmap[c_LimbCount, m_FrameCount]
152-
For Local row:Int = 0 To 3
153-
For Local frame:Int = 0 To m_FrameCount - 1
154-
'Grab pixmap inside tile bounds for saving
155-
framesToSave[row, frame] = GrabPixmap(63 + (frame * (m_TileSize / m_InputZoom + 8)), 139 + (row * 48), m_TileSize / m_InputZoom, m_TileSize / m_InputZoom)
156-
'HFlip the legs so they're facing right
157-
If row >= 2 Then
158-
framesToSave[row, frame] = XFlipPixmap(framesToSave[row, frame])
159-
EndIf
160-
Next
161-
Next
162-
g_FileIO.SaveFileAsFrames(framesToSave, m_FrameCount)
163-
EndIf
163+
'////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
164164

165-
ChangeBackgroundColor(m_BackgroundColor)
165+
Method GrabOutputFramesForSaving:TPixmap[,]()
166+
If m_SourceImage = Null Then
167+
Notify("Nothing to save!", False)
168+
Else
169+
ChangeBackgroundColor(c_Magenta)
170+
Draw()
171+
Flip(1) 'Have to flip again for background color to actually change, not sure why but whatever
172+
173+
Local framesToSave:TPixmap[c_LimbCount, m_FrameCount]
174+
For Local row:Int = 0 To 3
175+
For Local frame:Int = 0 Until m_FrameCount
176+
'Grab pixmap inside tile bounds for saving
177+
framesToSave[row, frame] = GrabPixmap(63 + (frame * (m_TileSize / m_InputZoom + 8)), 139 + (row * 48), m_TileSize / m_InputZoom, m_TileSize / m_InputZoom)
178+
'HFlip the legs so they're facing right
179+
If row >= 2 Then
180+
framesToSave[row, frame] = XFlipPixmap(framesToSave[row, frame])
181+
EndIf
182+
Next
183+
Next
184+
Return framesToSave
166185
EndIf
167-
168-
EndRem
169186
EndMethod
170187

171188
'////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

types/UserInterface.bmx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ Type UserInterface
137137
SetGadgetLayout(m_CanvasGraphics, m_CanvasGraphicsAnchor[0], m_CanvasGraphicsSize[0], m_CanvasGraphicsAnchor[1], m_CanvasGraphicsSize[1])
138138
SetGraphicsDriver(GLMax2DDriver())
139139
SetGraphics(CanvasGraphics(m_CanvasGraphics))
140+
SetClsColor(GadgetText(m_SettingsColorRTextbox).ToInt(), GadgetText(m_SettingsColorGTextbox).ToInt(), GadgetText(m_SettingsColorBTextbox).ToInt())
140141
EndMethod
141142

142143
'////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

0 commit comments

Comments
 (0)