Log In  


Hi! First thread here on the BBS.
I've looked around and can't see any mention of it. Maybe it's not known, or if it is known nobody has said anything about it? I don't know, but since I haven't seen any mention of it, I figured I would make a post about it!

I accidentally discovered that you can actually import PNG images directly to the sprite sheet. How? It's quite simple: place a PNG in your Picotron, e.g. /apps/png/. In Picotron's file explorer, navigate to the location of the PNG, select it, then either right-click and copy or Ctrl+C, switch to the sprite editor workspace, select the slot, then Ctrl+V to paste it.

I'm just getting started with Picotron after having spent a few weeks with Pico-8, and this has been, for me, the easiest way so far to get my sprites exported from Aseprite into my sprite sheet in Picotron. I'm trying to see if I can make a Picotron app that will take all the PNGs in a folder and import them to the sprite sheet, but in the meantime, this works well! It's tedious for many sprites, but if you just have a few sprites you want to import, it's quite easy and quick.

1


1

Wow! I didn't know that.
So it means I can save PNG files if I change my way of thinking.

...it worked!

c = {"ff974e75", "ffdf9abd"}
pixels = ""
for i=0, 63 do
  pixels = pixels .. c[i % 2 + 1]
end
store("/test.png", userdata("u32", 8, 8, pixels))

1

@sugarflower Oh wow! Very cool. This could be really helpful.. Using this we should then be able to export from sprite sheet to PNG right? I'm still figuring out how to do things with Picotron so I don't know much about the GFX format and its contents, but in theory this is possible, yes?

EDIT: Cool, so I podded a GFX file and copied it to the clipboard to see its contents. Just need to figure out how to convert that information to hex color values and write it out to u32 PNG! lol


When exporting from GFX to PNG,We should be aware that sprites can be a mixture of different sizes.It's a little difficult to figure out how to put it all together on a sheet.🤔


1

This is true. For now, however, I'd personally be quite happy with simply exporting each sprite into individual PNGs! Organizing it into a sheet would definitely be difficult... So for now I'm going to focus on just getting a single sprite into a PNG, and a single PNG into a sprite!


1

Is it something like this?
This is amazing, I always thought it was impossible.

function get_pal(idx)
  local p = peek4(0x5000 + idx*4)
  local r = p >> 16 & 0xff
  local g = p >> 8 & 0xff
  local b = p & 0xff
  local a = 0xff
  return string.format("%02x%02x%02x%02x", a, b, g, r)
end

function spr2png(spr_no, filepath)
  local s = get_spr(spr_no)
  local w, h = s:attribs()	
  local buf = ""

  for y = 0, h - 1 do
    for x = 0, w - 1 do
      local p = s[y*w+x]
      buf = buf .. get_pal(p)
    end
  end
  store(filepath, userdata("u32", w, h, buf))
end

--[[
Parameters:  sprite number, save png filepath
--]]
spr2png(1, "/test.png")
spr2png(2, "/heart.png")

Oh wow, that was fast. I'm still working on taking a PNG and directly copying it to the sprite editor without having to paste a userdata generated from the PNG. lol


To get png data,
we could use fetch.
To set data directly to gfx, we might be able to use set_spr() (maybe)

Thank you for this great opportunity, Cheer!


Maybe I used set_spr incorrectly, but it didn't seem to work when I tried it. I tried set_spr(1, ud) where ud is a u8 userdata I generated from a PNG. If I set_clipboard(pod(ud)) I can paste it into the sprite editor just fine, though.


I've got a resulting .gfx file but when I load it, it appears empty. I'm saving a table where bmp=userdata, and setting the flags, x_pan, y_pan, and zoom to 0.

{[0]={bmp=userdata("u8",32,32,"00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000121212000000000000121212120000000000000000000000000000000000121212121212000000001212121212120000000000000000000000000000000012121212121212000012121d1d1d1d12120000000000000000000000000000121212121212121212121212121d1d1d1d12000000000000000000000000000012121212121212121212121212121d1d1d1200000000000000000000000000001d121212121212121212121212121d1d1d1200000000000000000000000000001d12121212121212121212121212121d1d1200000000000000000000000000001d1d121212121212121212121212121d12120000000000000000000000000000001d121212121212121212121212121212000000000000000000000000000000001d1d121212121212121212121212121200000000000000000000000000000000001d1d1212121212121212121212120000000000000000000000000000000000001d1d1d1212121212121212121200000000000000000000000000000000000000001d1d1d1212121212121212120000000000000000000000000000000000000000001d1d1d12121212121212000000000000000000000000000000000000000000001d1d1d1d12121212121200000000000000000000000000000000000000000000001d1d1d1d12121212120000000000000000000000000000000000000000000000001d1d1d1d1212120000000000000000000000000000000000000000000000000000001d1d1d1d1d000000000000000000000000000000000000000000000000000000001d1d1d1d0000000000000000000000000000000000000000000000000000000000001d1d1d0000000000000000000000000000000000000000000000000000000000001d1d000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"),flags=0,pan_x=0,pan_y=0,zoom=0}}

As far as I can tell this is a valid format for a GFX file. Maybe it has to include the entire sprite sheet, not just a single sprite? lol I'm not sure. But hey, making some progress...
EDIT: Ah, just realized it should be pan_x and pan_y, not x_pan and y_pan... But even after correcting that, the GFX is still empty with the default x sprite at the beginning of the sheet lol


I found this really difficult.
The Picotron behaves as if each cartridge has its own world.
When I run the code below, it seems to set the sprite, but when I check in the GFX editor, I can't see its existence.
I think there's a clue here.

set_spr(1, userdata("u8", 3, 1, "070907"))
window {}
spr(1, 30, 30)

1

I've just achieved success! The code is messy, and I'm like 100% certain there's a better, smarter way to do it! But success is good!
For testing, I have a directory with the individual heart sprites from my Lovely Hearts screensaver. When I run the application, it grabs all the sprite PNG files from that directory, converts them to u8 userdata, and stores them in a .GFX file!

For now, the path and output are hard coded. My next step is to figure out how to create a windowed application to allow entering a folder path, an output path, and just click go.
EDIT: Oh, yeah, thanks @pancelor for sprimp! I took a gander at the code for sprimp and was able to see what I was doing wrong when constructing the GFX file's data. Thanks to that I was able to figure this out!


I'm still playing around with things and turns out you can also drag and drop PNG files into the sprite editor if you click and drag, use alt+left/right to move to the sprite editor workspace, and just drop it in.



[Please log in to post a comment]