Question

I am working on a small project involving PlayN. I am trying to make my own BitmapFont class where I need to be able to read individuel pixels from an Image, so I can hack up my image into letters. I can not seem to find any methods on Image or CanvasImage which allows me to do this.

Is there any other way I can achieve this in PlayN ?

Was it helpful?

Solution

You're probably better off doing whatever processing is needed to identify the glyphs in a bitmap font ahead of time and storing the metadata in a JSON file associated with the font image. Then at runtime your game would just load in the font image and the JSON metadata file and use the metadata to determine the bounds of each individual glyph.

You can do your preprocessing using standard Java classes like ImageIO and BufferedImage.

That said, it would probably not be too onerous to add a getColor(int x, int y) method to Canvas, as I believe the technology that underlies Canvas on each of the different supported platforms provides a way to read a pixel from the image.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top