CPCWiki forum

General Category => Programming => Topic started by: zhulien on 03:34, 04 October 21

Title: PNG to CPC for Open Street Maps mapping... Games using Maps Anyone?
Post by: zhulien on 03:34, 04 October 21
Hi,has anyone written logic for PNG loading on a CPC,or better still... in PHP taking a PNG file and converting it to CPC (Mode 1 is preferable, but possibly mode 0).


Something like this but in PHP, not GO


https://github.com/jeromelesaux/martine (https://github.com/jeromelesaux/martine) 

Julian

Title: Re: PNG to CPC
Post by: eto on 09:43, 04 October 21
I've done something in JAVA that accepts any 160x200 image and converts it into a SCR file (MODE 0). Very simplistic and not much more than a script. I can post the source code if that helps to understand the process.
Title: Re: PNG to CPC
Post by: Bryce on 09:54, 04 October 21
I had a program (not written by me) that converted BMP to CPC. I'll see if I can find that.

Bryce.


Edit: Found it: https://www.cpcwiki.eu/index.php/ConvImgCPC
Title: Re: PNG to CPC
Post by: eto on 11:03, 04 October 21
Martine: https://github.com/jeromelesaux/martine
Title: Re: PNG to CPC
Post by: ajcasado on 11:46, 04 October 21
Something like this but in PHP, not GO

https://github.com/jeromelesaux/martine (https://github.com/jeromelesaux/martine) 
You can run the martine shell executable from PHP.
Title: Re: PNG to CPC
Post by: MiguelSky on 12:29, 04 October 21
El CPC Paint included on JavaCPC works quite well.


EDITO: Oh, I missed the PHP part of thew request  :picard:
Title: Re: PNG to CPC
Post by: zhulien on 15:39, 05 October 21
I have put in place some image processing for PNG to an output, the output i can write whatever i choose - either a CPC sprite in a given mode.
Title: Re: PNG to CPC
Post by: zhulien on 18:01, 05 October 21
This is only a POC, it is doing the first bit consisting of a bit of my code and another service. 


I was thinking if Open Street Maps is available for CPC, it could be useful for some games.  I have specifically locked the coordinates, for now but you can play with the zoom level.

It is retrieving a PNG, but ultimately it would have the option to retrieve a CPC-compatible sprite.  I have fixed the tile size to 200x200pixels which fits nicely in Mode 1.  I am thinking Mode 1 has enough colours to make the map recognisable still.


https://8bitology.net/poc/cpcmap/cpcmap.php?zoom=16  (zoom is valid between 0 and 19).

The terrain option uses a different 3rd party service again that likely I cannot redevelop.

https://8bitology.net/poc/cpcmap/cpcmap.php?zoom=15&style=terrain (zoom is valid between 0 and 15)
Title: Re: PNG to CPC
Post by: zhulien on 18:09, 05 October 21
btw, if i were to make a game, I would either use Mode 1 with the map to the right or left leaving 120 pixels for menus, scoring, statuses etc (thinking Red Alert on a global scale)...  or a vertical orientation like Arkanoid could work too.  Being Vertical would make it easier to switch between tiles of eg: streets (4 colours) vs terrain (16 colours) with a split mode for scores etc.


Once converted to CPC sprite and compressed (RLE?) then the file sizes should be very small, and the M4 can quickly transfer them to SD Card for CPC's local caching.

https://8bitology.net/poc/cpcmap/cpcmap.php?zoom=8&style=terrain (https://8bitology.net/poc/cpcmap/cpcmap.php?zoom=8& class=bbc_link target=_blank rel=noopener)  (perhaps terrain would look better in mode 0?)


The 3rd image below is equivalent to the 200x200 one, but double-width pixels of mode 0 (on CPC it would be 100x200).



Title: Re: PNG to CPC for Open Street Maps mapping... Games using Maps Anyone?
Post by: zhulien on 18:18, 05 October 21
To map RGB values from a PNG to the CPC pallet, what would be a good algorithm for colour reduction?