Skip to content

Commit 046e4be

Browse files
committed
Adding ASEPRITE to main LIB README, and adding ASEPRITE README
1 parent f662472 commit 046e4be

File tree

7 files changed

+87
-4
lines changed

7 files changed

+87
-4
lines changed

ASEPRITE/ASEPRITE.BAS

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ $CONSOLE
2121

2222
DIM filename AS STRING
2323
DIM aseprite_image AS LONG
24+
DIM ZOOM AS INTEGER
25+
ZOOM = 10
2426

2527
filename = "test-files/DJ Trapezoid - Pumpkin Head.aseprite"
2628

@@ -33,12 +35,14 @@ IF aseprite_image& = 0 THEN
3335
END IF
3436

3537
_TITLE "ASEPRITE ImageViewer"
36-
SCREEN _NEWIMAGE(_WIDTH(aseprite_image&), _HEIGHT(aseprite_image&), 32)
38+
SCREEN _NEWIMAGE(_WIDTH(aseprite_image&) * ZOOM, _HEIGHT(aseprite_image&) * ZOOM, 32)
3739
_SCREENMOVE _MIDDLE
3840
_SOURCE aseprite_image&
3941
_DEST 0
4042
_PUTIMAGE
41-
SLEEP
43+
DO
44+
' WAIT FOR ESC
45+
LOOP UNTIL _KEYHIT = 27
4246

4347
SYSTEM 1
4448

ASEPRITE/ASEPRITE.BI

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -754,6 +754,7 @@ TYPE ASEPRITE_RENDER_ITEM
754754
END TYPE
755755

756756
' Function declarations for basic and enhanced layer support
757+
DECLARE FUNCTION load_aseprite_file& (filename AS STRING)
757758
DECLARE SUB load_aseprite_image (img_path$, result AS ASEPRITE_IMAGE)
758759
DECLARE SUB load_aseprite_enhanced (file_path$, result AS ASEPRITE_ENHANCED_IMAGE)
759760

ASEPRITE/ASEPRITE.png

6.98 KB
Loading

ASEPRITE/README.md

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# [QB64_GJ_LIB](../README.md)
2+
## GRYMMJACK'S ASEPRITE LIBRARY
3+
4+
Adds native [ASEPRITE](https://www.aseprite.org/) support to QB64!
5+
6+
### USAGE for Dict Object (separately)
7+
```basic
8+
'Insert at top of file:
9+
'$INCLUDE:'path_to_GJ_LIB/ASEPRITE/ASEPRITE.BI' at the top of file
10+
11+
' ...your code here...
12+
13+
'Insert at bottom of file:
14+
'$INCLUDE:'path_to_GJ_LIB/ASEPRITE/ASEPRITE.BM' at the bottom of file
15+
```
16+
17+
18+
19+
## WHAT'S IN THE LIBRARY (WIP)
20+
| SUB / FUNCTION | NOTES |
21+
|----------------|-------|
22+
| load_aseprite_image | Loads a .ase/.aseprite file into an ASEPRITE_IMAGE structure
23+
| get_aseprite_info$ | Returns human-readable information about an ASEPRITE_IMAGE
24+
| is_valid_aseprite_file | Checks whether a file is a valid Aseprite file
25+
| get_aseprite_extension$ | Returns the canonical Aseprite file extension (".ase")
26+
| get_blend_mode_name$ | Maps blend mode constant to descriptive string
27+
| get_animation_direction_name$ | Maps animation direction constant to descriptive string
28+
| create_image_from_aseprite&| Creates a QB64PE image handle from loaded Aseprite pixel data
29+
| display_aseprite_image | Draws an ASEPRITE_IMAGE to the screen (with scale/centering)
30+
| preview_aseprite_image | Quick preview helper (original size)
31+
| preview_aseprite_scaled | Scaled preview helper (e.g. 2x)
32+
| load_aseprite_pixels% | Attempts to load pixel data from file chunks into an image
33+
| load_raw_pixel_data% | Reads uncompressed pixel data into a target image
34+
| load_compressed_pixel_data% | Decompresses zlib-compressed cel data into an image
35+
| load_compressed_pixel_data_for_layer% | Specialized loader for layer extraction (positions at 0,0)
36+
| create_compressed_placeholder% | Fallback placeholder renderer for compressed data (uses _INFLATE$)
37+
| get_indexed_color& | Returns RGB color for an indexed palette entry
38+
| load_aseprite_enhanced | Loads enhanced ASEPRITE data with layers and animation metadata
39+
| parse_layer_chunks% | Parses layer chunk data from file into structures
40+
| parse_frame_chunks% | Parses frame and timing chunks from file
41+
| init_aseprite_animation | Initializes animation timing/state for enhanced images
42+
| update_aseprite_animation| Advances animation timing and handles frame progression
43+
| play_aseprite_animation | Starts/resumes animation playback
44+
| pause_aseprite_animation | Pauses animation playback
45+
| set_aseprite_frame | Sets the current animation frame (by index)
46+
| get_aseprite_layer_count%| Returns number of layers in ASEPRITE_IMAGE
47+
| get_aseprite_frame_count%| Returns number of frames in ASEPRITE_IMAGE
48+
| get_aseprite_cel_count% | Returns total number of cels in ASEPRITE_IMAGE
49+
| get_aseprite_tag_count% | Returns number of animation tags in ASEPRITE_IMAGE
50+
| is_valid_layer_index% | Validates a layer index against an ASEPRITE_IMAGE
51+
| is_valid_frame_index% | Validates a frame index against an ASEPRITE_IMAGE
52+
| get_layer_count% | Returns layer count for ASEPRITE_ENHANCED_IMAGE
53+
| get_layer_name$ | Returns the name of a layer in an enhanced image
54+
| is_layer_visible% | Checks whether a layer is currently visible
55+
| set_layer_visibility | Set visibility for a layer and update composite image
56+
| update_composite_image | Rebuilds composite image from visible layers
57+
| load_specific_layer_image& | Extracts a single layer's pixels into a QB64PE image
58+
| load_specific_layer_image_enhanced& | Enhanced layer extraction with improved scope handling
59+
| create_aseprite_image_from_layer& | High-level wrapper to create an image from a named/indexed layer
60+
| create_full_composite_image& | Composites all layers for a given frame into a single image handle
61+
| load_aseprite_file& | Top-level convenience loader that returns a composite image handle
62+
63+
### SAMPLE PROGRAMS
64+
- [ASEPRITE.BAS](ASEPRITE.BAS) - Simple implementation to load a `.aseprite` image
65+
- [WORKING-KEEP-debug_layers_example.bas](WORKING-KEEP-debug_layers_example.bas) - WIP on showing how to load layers
66+
- [WORKING-KEEP-visual_pumpkin_viewer.bas](WORKING-KEEP-visual_pumpkin_viewer.bas) - WIP on showing how to load a single layer at various sizes
67+
68+
### SCREENSHOTS
69+
> Screenshot of output from [ASEPRITE.BAS](ASEPRITE.BAS)
70+
![Example output from [ASEPRITE.BAS](ASEPRITE.BAS)](ASEPRITE.png)
71+
72+
> Screenshot of output from [WORKING-KEEP-visual_pumpkin_viewer.BAS](WORKING-KEEP-visual_pumpkin_viewer.BAS)
73+
![Example output from [WORKING-KEEP-visual_pumpkin_viewer.BAS](WORKING-KEEP-visual_pumpkin_viewer.BAS)](WORKING-KEEP-visual_pumpkin_viewer.png)
74+
![alt text](image.png)

ASEPRITE/WORKING-KEEP-visual_pumpkin_viewer.bas

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55

66
'$INCLUDE:'ASEPRITE.BI'
77

8+
$CONSOLE
9+
810
' Constants
911
CONST TEST_FILE$ = "test-files\DJ Trapezoid - Pumpkin Head.aseprite"
1012

@@ -101,8 +103,9 @@ ELSE
101103
_PRINTSTRING (10, 110), "Press any key to exit..."
102104
END IF
103105

106+
DO
104107
' Wait for user input
105-
SLEEP
108+
LOOP UNTIL _KEYHIT = 27
106109
SYSTEM
107110

108111
'$INCLUDE:'ASEPRITE.BM'
24.7 KB
Loading

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# QB64_GJ_LIB
22
## GRYMMJACK'S QB64 LIBRARY
33

4-
# REQUIRES QB64-PE V3.12+
4+
# REQUIRES QB64-PE V4+
55

66
### WHAT IS THIS?
77
> This is a library of QB64 code which I've created to fill in some "holes" that I
@@ -14,6 +14,7 @@ in it's current state.
1414
| LIBRARY | PURPOSE | NOTES |
1515
|---------|---------|------|
1616
| [ANSI](ANSI/README.md) | ANSI text mode | Full ANSI.SYS support plus 256 and RGB color modes as well as a QB64 native ansi emulation mode. |
17+
| [ASEPRITE](ASEPRITE/README.md) | [ASEPRITE](https://www.aseprite.org/) Image Format support | Natively use `.aseprite` files in QB64! |
1718
| [ARR](ARR/README.md) | ARRay Library | A high level library for working with arrays of all types in QB64 |
1819
| [BBX](BBX/README.md) | Bounding BoX Library | Reusable bounding box with position, resize, keyboard and mouse control |
1920
| [DICT](DICT/README.md) | Dictionary object (sorta) | Custom type and support for arrays using `.key` and `.val` |

0 commit comments

Comments
 (0)