Skip to content

Commit 5e4a253

Browse files
authored
Merge pull request #6 from cortex-command-community/development
Merge v1.3.0 into Master
2 parents d7de156 + 8b4a39c commit 5e4a253

File tree

10 files changed

+180
-34
lines changed

10 files changed

+180
-34
lines changed

.gitignore

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
11
/.bmx
22
*.exe
3-
*.bak
3+
*.bak
4+
*.png
5+
*.bmp
6+
7+
!test-image.bmp
8+
!input-template.bmp

README.md

Lines changed: 41 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,27 +17,60 @@ Arne's original bend code was used as base and has been modified and improved to
1717
- GUI
1818
- Loading/saving files.
1919
- Adjusting joint position.
20-
- Zoom setting for easy joint adjustment.
20+
- Zoom setting on input image for easy joint adjustment.
2121
- Frames number output setting.
2222
- Background color setting.
2323
- Automatic setting of background color to magenta on save.
24-
- Saving as PNG or Indexed BMP (CC Palette)
24+
- Saving as PNG or Indexed BMP (CC Palette).
25+
- Saving as individual named frames.
2526

2627
## How To
2728

2829
1. Create an input file using the provided template.
29-
2. Load your file in the app.
30+
- **Warning:** The order of limb parts in the input file **is important!**
31+
- Order should be as specified, going left to right:
32+
Upper Arm FG, Lower Arm FG, Upper Arm BG, Lower Arm BG, Upper Leg FG, Lower Leg FG, Upper Leg BG, Lower Leg BG.
33+
- **Double Warning:**
34+
- Arm parts should be facing **right** for correct bending!
35+
- Leg parts should be facing **left** for correct bending!
36+
37+
- See included "test-image.bmp" to understand how your input file should look like.
38+
39+
2. Load your input file using the "**Load**" button.
40+
3041
3. Bent limbs will auto generate with default settings.
42+
3143
4. Adjust joint positions by clicking on the upper joint marker and dragging it around.
32-
- Use **Zoom** setting to enlarge the input image for easier joint adjustment
44+
- ~~Use **Zoom** setting to enlarge the input image for easier joint adjustment~~
45+
- Input image will be automatically zoomed to x4 on first load.
3346
- **Warning:** When zooming the joint markers will reset to original positions. First zoom, then adjust.
47+
3448
5. Use **Frames** setting to set number of bend frames.
3549
- Bend angle will adjust automatically. First/Last frames will always be fully bent/unbent.
50+
3651
6. Decide whether you want to save as Indexed BMP or not - if yes, tick the "**Save as Indexed Bitmap**" checkbox.
37-
7. Hit save
38-
- Background color will automatically be set to magenta (255,0,255) when save is clicked and will revert back to previous color when finished.
39-
8. Slice the saved image into frames and apply palette.
40-
- Manually touch-up the exported frames if needed.
52+
53+
7. Decide whether you want to save as individual named frames or not - if yes, tick the "**Save as Frames**" checkbox.
54+
- Exported frame size is fixed to 24x24px.
55+
- If enabled, a visual aid will be shown around each frame to help the user stay within bounds.
56+
- Pixels outside bounds will be cropped.
57+
- Exported leg frames will be automatically flipped horizontally to face right.
58+
59+
**Note:** "Save as Indexed Bitmap" and "Save as Frames" do not conflict and can be used together to export indexed individual frames.
60+
61+
8. Hit save
62+
- Background color will automatically be set to magenta (255,0,255) when save is clicked and will revert back to previous color when finished.
63+
64+
- **Warning:**
65+
- File extension will be added automatically depending on selected "**Save as Indexed Bitmap**" setting so there is no need to add it manually.
66+
Doing so will resolve in a double extension (for example: "MyFile.png.png").
67+
68+
- **Quadruple Warning:**
69+
70+
- When saving with "**Save as Frames**" enabled, only input the name of the actor these limbs belong to (for example: "Robot").
71+
Limb names and frame numbers will be added automatically.
72+
**Adding the limb name and frame number manually will result in horrible exported file names.**
73+
4174

4275
## Current Issues
4376

assets.bmx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ Incbin "assets/palette"
88
'Embed logo image for standalone exe
99
Incbin "assets/logo-image"
1010

11+
'Embed tile image for standalone exe
12+
Incbin "assets/tile"
13+
1114
'Embed textbox contents to later load into strings
1215
Incbin "assets/about-textbox-content"
1316
Incbin "assets/help-textbox-content"

assets/help-textbox-content

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,4 +63,16 @@ When not ticked, output will be saved as a non-indexed PNG.
6363
THE INDEXING PROCESS IS SLOW!
6464
I've done my best to speed it up but it still isn't blazing fast like PNG saving.
6565
When saving indexed, the app may hang and appear unresponsive but in fact it's doing what it's supposed to.
66-
For best results, DO NOT TOUCH ANYTHING until the background color reverts from magenta to whatever it was before!
66+
For best results, DO NOT TOUCH ANYTHING until the background color reverts from magenta to whatever it was before!
67+
68+
69+
SAVE AS FRAMES:
70+
When ticked each frame of the output will be exported as an individual file.
71+
Exported frame size is fixed to 24x24px. A bounding box will be shown around each frame to help user stay within bounds.
72+
Anything outside bounds will be cropped.
73+
74+
Does not conflict with "SAVE AS INDEXED BITMAP" and can be used together to export indexed individual frames.
75+
76+
- Quadruple Warning :
77+
WHEN SAVING, DO NOT MANUALLY ADD LIMB NAME OR FRAME NUMBER TO FILE NAME. THIS IS DONE AUTOMATICALLY.
78+
DOING SO WILL RESULT IS HORRIBLE HORRIBLE EXPORTED FILE NAMES.

assets/tile

1.84 KB
Binary file not shown.

bender.bmx

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,10 @@ Include "types/file-io.bmx"
2222
Include "types/bitmap-index.bmx"
2323

2424
'Version
25-
Global appVersion:String = "1.2.2"
26-
Global appVersionDate:String = "14 Feb 2020"
25+
Global appVersion:String = "1.3.0"
26+
Global appVersionDate:String = "16 Feb 2020"
27+
28+
AppTitle = "CCCP Bender v"+appVersion
2729

2830
Rem
2931
------- BOOT ----------------------------------------------------------------------------------------------------------
@@ -40,7 +42,7 @@ Rem
4042
------- EVENT HANDLING ------------------------------------------------------------------------------------------------
4143
EndRem
4244

43-
While True
45+
While True
4446
TAppOutput.FOutputUpdate()
4547

4648
If ButtonState(TAppGUI.editSettingsIndexedCheckbox) = True Then
@@ -50,11 +52,19 @@ While True
5052
fileFilters = "Image Files:png"
5153
TAppFileIO.saveAsIndexed = False
5254
EndIf
55+
56+
If ButtonState(TAppGUI.editSettingsSaveAsFramesCheckbox) = True Then
57+
TAppFileIO.saveAsFrames = True
58+
Else
59+
TAppFileIO.saveAsFrames = False
60+
EndIf
5361

54-
WaitEvent
55-
'Print CurrentEvent.ToString()
56-
'Print GCMemAlloced()
62+
'Debug stuff
63+
'Print "current event: " + CurrentEvent.ToString()
64+
'Print "allocated memory in bytes: " + GCMemAlloced() 'not sure how accurate this really is, numbers don't match with task manager
65+
'Print "mouse position in canvas: x = " + MouseX() + " y = " + MouseY()
5766

67+
PollEvent
5868
'Event Responses
5969
Select EventID()
6070
Case EVENT_APPRESUME
@@ -67,7 +77,6 @@ While True
6777
Case EVENT_MENUACTION
6878
Select EventData()
6979
Case TAppGUI.ABOUT_MENU
70-
AppTitle = "CCCP Bender v"+appversion
7180
Notify(LoadText("Incbin::assets/about-textbox-content"),False)
7281
EndSelect
7382
Case EVENT_GADGETACTION
@@ -81,8 +90,12 @@ While True
8190
TAppOutput.FOutputUpdate()
8291
'Saving
8392
Case TAppGUI.editSaveButton
84-
TAppFileIO.prepForSave = True
85-
TAppOutput.FOutputUpdate()
93+
If TAppOutput.sourceImage <> Null Then
94+
TAppFileIO.prepForSave = True
95+
TAppOutput.FOutputUpdate()
96+
Else
97+
Notify("Nothing to save!",False)
98+
EndIf
8699
'Settings textbox inputs
87100
'Scale
88101
Case TAppGUI.editSettingsZoomTextbox
File renamed without changes.

types/editor-output.bmx

Lines changed: 40 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -163,20 +163,11 @@ Type TAppOutput
163163
b = 7 SetRotation(angle[b,f]) DrawImageRect(boneImage[b],xBone[b,f],yBone[b,f],ImageWidth(boneImage[b])/INPUTZOOM,ImageHeight(boneImage[b])/INPUTZOOM)
164164
Next
165165
SetRotation(0)
166+
FGrabOutputForSaving()
166167
Else
167168
SetColor(255,230,80)
168-
DrawText("NO IMAGE LOADED!",(GraphicsWidth()/2)-(TextWidth("NO IMAGE LOADED!")/2),GraphicsHeight()/2)
169-
EndIf
170-
'Output copy for saving
171-
If TAppFileIO.saveAsIndexed = True Then
172-
'If saving indexed grab a smaller pixmap to speed up indexing
173-
TAppFileIO.tempOutputImage = GrabPixmap(55,120,34*FRAMES,210)
174-
Else
175-
TAppFileIO.tempOutputImage = GrabPixmap(0,96,768,384)
176-
EndIf
177-
Flip(1)
178-
If TAppFileIO.prepForSave
179-
TAppFileIO.FPrepForSave()
169+
DrawText("NO IMAGE LOADED!",(GraphicsWidth()/2)-(TextWidth("NO IMAGE LOADED!")/2),GraphicsHeight()/2)
170+
Flip(1)
180171
EndIf
181172
EndFunction
182173

@@ -206,4 +197,41 @@ Type TAppOutput
206197
FLimbBend()
207198
FOutputUpdate()
208199
EndFunction
200+
201+
'Output copy for saving
202+
Function FGrabOutputForSaving()
203+
If TAppFileIO.saveAsFrames = True Then
204+
Local row:Int, frame:Int
205+
Local tile:TImage = LoadImage("Incbin::assets/tile")
206+
For row = 0 To 3
207+
For frame = 0 To FRAMES-1
208+
'Draw a tile outline around all frames to see we are within bounds.
209+
DrawImage(tile,62+(frame*(TILESIZE/INPUTZOOM+8)),138+(row*48)) 'Doing this with an image because cba doing the math with DrawLine. Offsets are -1px because tile image is 26x26 for outline and tile is 24x24.
210+
'Draw names of rows
211+
SetColor(255,230,80)
212+
DrawText("Arm FG",8,145)
213+
DrawText("Arm BG",8,145+48)
214+
DrawText("Leg FG",8,145+(48*2))
215+
DrawText("Leg BG",8,145+(48*3))
216+
'Grab pixmap inside tile bounds for saving
217+
TAppFileIO.tempOutputFrame[row,frame] = GrabPixmap(63+(frame*(TILESIZE/INPUTZOOM+8)),139+(row*48),TILESIZE/INPUTZOOM,TILESIZE/INPUTZOOM)
218+
'HFlip the legs so they're facing right
219+
If row >= 2 Then
220+
TAppFileIO.tempOutputFrame[row,frame] = XFlipPixmap(TAppFileIO.tempOutputFrame[row,frame])
221+
EndIf
222+
Next
223+
Next
224+
Else
225+
If TAppFileIO.saveAsIndexed = True Then
226+
'If saving indexed grab a smaller pixmap to speed up indexing
227+
TAppFileIO.tempOutputImage = GrabPixmap(55,120,34*FRAMES,210)
228+
Else
229+
TAppFileIO.tempOutputImage = GrabPixmap(0,96,768,384)
230+
EndIf
231+
EndIf
232+
Flip(1)
233+
If TAppFileIO.prepForSave
234+
TAppFileIO.FPrepForSave()
235+
EndIf
236+
EndFunction
209237
EndType

types/file-io.bmx

Lines changed: 50 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,14 @@ Type TAppFileIO
1515

1616
'Save Bools
1717
Global saveAsIndexed:Int = False
18+
Global saveAsFrames:Int = False
1819
Global prepForSave:Int = False
1920
Global rdyForSave:Int = False
2021
Global runOnce:Int = False
2122

2223
'Output copy for saving
2324
Global tempOutputImage:TPixmap
25+
Global tempOutputFrame:TPixmap[4,20] 'noice
2426

2527
'Load Source Image
2628
Function FLoadFile()
@@ -48,7 +50,11 @@ Type TAppFileIO
4850
runOnce = True
4951
TAppOutput.FOutputUpdate()
5052
Else
51-
FSaveFile()
53+
If Not saveAsFrames Then
54+
FSaveFile()
55+
Else
56+
FSaveFileAsFrames()
57+
EndIf
5258
EndIf
5359
EndIf
5460
EndFunction
@@ -66,7 +72,7 @@ Type TAppFileIO
6672
'Foolproofing
6773
If exportedFile = importedFile Then
6874
Notify("Cannot overwrite source image!",True)
69-
ElseIf exportedFile <> importedFile Then
75+
ElseIf exportedFile <> importedFile And exportedFile <> Null Then
7076
'Writing new file
7177
If saveAsIndexed = True
7278
TBitmapIndex.FPixmapToIndexedBitmap(tempOutputImage,exportedFile)
@@ -79,4 +85,46 @@ Type TAppFileIO
7985
FRevertPrep()
8086
EndIf
8187
EndFunction
88+
89+
'Save Output Content As Frames
90+
Function FSaveFileAsFrames()
91+
exportedFile = RequestFile("Save graphic output","",True) 'No file extensions here, we add them later manually otherwise exported file name is messed up.
92+
'Foolproofing
93+
If exportedFile = importedFile Then
94+
Notify("Cannot overwrite source image!",True)
95+
ElseIf exportedFile <> importedFile And exportedFile <> Null Then
96+
'Writing new file
97+
Local row:Int, frame:Int
98+
For row = 0 To 3
99+
'Name the rows - by default: ArmFG, ArmBG, LegFG, LegBG in this order.
100+
Local rowName:String
101+
If row = 0 Then
102+
rowName = "ArmFG"
103+
ElseIf row = 1 Then
104+
rowName = "ArmBG"
105+
ElseIf row = 2 Then
106+
rowName = "LegFG"
107+
ElseIf row = 3 Then
108+
rowName = "LegBG"
109+
EndIf
110+
For frame = 0 To TAppOutput.FRAMES-1
111+
Local exportedFileTempName:String
112+
If frame < 10 Then
113+
exportedFileTempName = exportedFile+rowName+"00"+frame
114+
Else
115+
exportedFileTempName = exportedFile+rowName+"0"+frame
116+
EndIf
117+
If saveAsIndexed = True
118+
TBitmapIndex.FPixmapToIndexedBitmap(tempOutputFrame[row,frame],exportedFileTempName+".bmp")
119+
Else
120+
SavePixmapPNG(tempOutputFrame[row,frame],exportedFileTempName+".png")
121+
EndIf
122+
Next
123+
Next
124+
FRevertPrep()
125+
Else
126+
'On Cancel
127+
FRevertPrep()
128+
EndIf
129+
EndFunction
82130
EndType

types/user-interface.bmx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ Type TAppGUI
3636
Global editSettingsColorBLabel:TGadget
3737
Global editSettingsIndexedLabel:TGadget
3838
Global editSettingsIndexedCheckbox:TGadget
39+
Global editSettingsSaveAsFramesLabel:TGadget
40+
Global editSettingsSaveAsFramesCheckbox:TGadget
3941
'Editor Window Help
4042
Global editHelpPanel:TGadget
4143
Global editHelpTextbox:TGadget
@@ -64,7 +66,9 @@ Type TAppGUI
6466
editSettingsColorGLabel = CreateLabel("G:",120,45,50,20,editSettingsPanel,LABEL_LEFT)
6567
editSettingsColorBLabel = CreateLabel("B:",175,45,50,20,editSettingsPanel,LABEL_LEFT)
6668
editSettingsIndexedLabel = CreateLabel("Save as Indexed Bitmap:",10,75,130,20,editSettingsPanel,LABEL_LEFT)
67-
editSettingsIndexedCheckbox = CreateButton("",140,73,20,20,editSettingsPanel,BUTTON_CHECKBOX)
69+
editSettingsIndexedCheckbox = CreateButton("",140,75,15,15,editSettingsPanel,BUTTON_CHECKBOX)
70+
editSettingsSaveAsFramesLabel = CreateLabel("Save as Frames:",160,75,80,20,editSettingsPanel,LABEL_LEFT)
71+
editSettingsSaveAsFramesCheckbox = CreateButton("",250,75,15,15,editSettingsPanel,BUTTON_CHECKBOX)
6872
editHelpPanel = CreatePanel(10,203,280,250,editWindow,PANEL_GROUP," Help : ")
6973
editHelpTextbox = CreateTextArea(7,5,GadgetWidth(editHelpPanel)-21,GadgetHeight(editHelpPanel)-32,editHelpPanel,TEXTAREA_WORDWRAP|TEXTAREA_READONLY)
7074
'Populate textboxes

0 commit comments

Comments
 (0)