Sprite Not Importing Correctly!

So, I have been making my art in Pulp for weeks now, and I have been doing it sprite-by-sprite. It didn't bother me at first, but as I worked on my game, it slowed my progress. I've already been trying to tinker with it for a week now.

This is the test image, a 64x64 with a white square in the middle.

test-table-8-8.png

I tried this format,

Screenshot_5

this is how it turned out,

Screenshot_3

and this format,

Screenshot_6

this is how it turned out,

neither worked.

The black parts of the image have been turned into a jumbled mess. I don't know if I missed something from the aforementioned solutions, or if there is a problem with my PC. I saw some people who had the same problem, but I haven't found anyone that had an answer or had a solution for them. Is there a way to fix this?

Thank you for your help!

Only two things I can think of at the moment.

First thing is double-check if your PNG has a transparency layer. I've discovered Pulp has a problem importing when there's an alpha channel.

Second, on your 2nd import attempt, you have a file name with "count-4096", which from my own limited experience with importing means it will try to slice your image into 4096 8x8 tiles and put them into 4k frames of animation for that single tile. Your image doesn't have that many tiles to slice though. I wonder if Pulp can handle that many frames in a single tile, or what does it do when you ask to make more tiles than exists in your image.

That being said I tried importing your test image with name test-table-8-8.png and didn't have any problems...

1 Like

Thanks for replying!

How do I check if it has a transparency layer?

Yeah, that "count-4096" was indeed wrong. It was still imported though, albeit incorrectly.

Did you download the same image? Because if you did, I don't know why it would work for you and not for me.

I tried using another device, this time on a Mac, downloaded the same image, but still didn't work.

How do I check if it has a transparency layer?

Unless you're using something like Photoshop or Gimp, etc, which will show if there's an alpha channel, one easy way is open it in MS Paint and save it as a JPEG. If it has a transparency layer, it will ask you if you're okay with removing transparency. If it doesn't ask, there's no transparency there.

Did you download the same image? Because if you did, I don't know why it would work for you and not for me.

Yeah, I right-click->saved the image you shared in your first post above. Named it the same and imported it without a hitch.

I'm using Aseprite. Still, I tried saving it in MS Paint like you said, and it still didn't work.

I don't know what the problem is. I tried exporting an existing sprite and importing it.

An 8x8 Player sprite

pulp-tiles-layer-Player-count-1-table-8-8

Now it became like this.

Are you using any browser extensions like Pulp+?

No, I have never heard of Pulp+. What is it though?

Pulp+ is browser extension that affects some visibility/quality of life/access features of Pulp in your browser.

But, I guess that's not the case here. I'm stumped as to why you're having import problems.

I'm also stumped. Thanks for helping, though!

Do you have a link for Pulp+? I didn't know there was such a thing. Many Thanks!

Edit: nvm, found the link!

so yeah Pulp really doesn't like transparency but also can have issues dealing with even infinitesimally different shades of black and white. For ART7 I import a ton of art into a single tile apiece and I know pulp can handle 1000+ frames just fine. if I use my process to draw the art over a bunch of tiles sometimes it will look funny because the art actually had a few different shades of black used in it and pulp misinterprets some of those as white.

SO. I take that image into photoshop (I'm sure other programs will work similar) and I pick another color to use like RED and use the paint bucket on a black space. If you use the paint bucket and uncheck the box for "continuous" it should fill ALL the black spaces of exactly that same shade and you can see if there are any variances and then fill those as well until all the black is replaced with red. Then you just make the paint bucket black again, change all the red Back to black and import. I've only had to do this once for white.

it can be tedious but is the quickest way I've found to ferret out differences in shades and get everything looking right.

1 Like

Thanks for replying!

I see what you mean by that. I have also done that, and it hasn't worked for me. If transparency was indeed the problem, I don't know why it would not import correctly for exported sprites that came originally from pulp.

Did you try right-click->saving the image off the forum that you shared, and then import that with filename test-table-8-8.png? Because that's exactly what I did.
Because if it still fails, I doubt there's anything wrong with the picture.

Yes, I did.

incorrect_import

Well, I would have believed you. I didn't need the gif proof lol :smile:

This, I cannot explain. Different computers with different browsers, same problem?

1 Like

I tried using Microsoft Edge and it worked! For some reason, importing sprites into pulp using Brave Browser right now doesn't properly work. I hope this will be fixed in the future. Now that'll speed up progress! Thank you so much for the help!

EDIT: Found the culprit, it’s the ad blockers that ruin the imported sprites!

1 Like

Colorful assets

So the guidance is your artwork should have true black #000000 or white #FFFFFF pixels. This works. ...But perhaps we want to do something funky and import other tinted monotone images?... such as using Playdate's own brand palette (#b1aea8, #322f27). This does not work... :frowning:

TL;DR

Due to the current import code (6-Jul-2023) :

  • Your 'black' tone (for set /on pixels =1) must not contain any red channel color (but green and blue can have any value). e.g. #00FFFF will work!
  • Your 'white' tone (for unset /off pixels =0) can have any value, as long as the red channel is 1-255 (not zero). e.g. #FFFF00 will work!
  • Avoid any transparency for background tiles.

Deeper dive

It's a shame the code isn't open sourced... so to understand the code importing images, I had to debug in the browser. The relevant function is importPixels from the main pulp.xxxx.js script. The code reads each pixel value of a canvas element, getting 4 bytes (RGBA) per pixel with getImageData.

The logic to determine whether a pixel is set 1 (black) or unset 0 (white) is:

(imageData[j]==0?1:0)

where j is the first byte of a pixel. So... we are just checking the Red channel value is equal to zero (dark) to give a black, set 1 pixel. Any other Red value gives us an unset 0 pixel. This isn't unreasonable and is a commonly used approach.

But, a trivial fix might be to threshold the R channel at 127, to separate light and dark tones:

(imageData[j]<128?1:0)

This would then work with Playdate's own brand palette (and most others). Hopefully this gets fixed :pray:

In the meantime, after tweaking palettes, I found one I like:
:white_large_square: Background 'white' #B1AEA8 / RGB(177,174,168) - Playdate standard.
:black_large_square: Foreground 'black' #001020 / RGB(0,16,32) - Very dark indigo.


09-ConfettiLarge-table-8-8

Cheers!