PNGtoUDG

You need an actual VIC.

Moderator: Moderators

Post Reply
User avatar
Kweepa
Vic 20 Scientist
Posts: 1314
Joined: Fri Jan 04, 2008 5:11 pm
Location: Austin, Texas
Occupation: Game maker

PNGtoUDG

Post by Kweepa »

Hi,
I had some UDGs designed in PNG, laid out as 8x8 tiles, so I wrote a little program to extract data statements for them.

http://www.kweepa.com/step/vic20/PNGToUDG.exe

You just place it in a directory containing PNGs and it writes data statements to the standard output.

Code: Select all

> dir /b
spr.png
lad.png
> PNGToUDG > udg.txt
> type udg.txt
; spr.png
defb 0, 1, 255, 128, 127, 33, 31, 255
defb 0, 1, 255, 128, 127, 31, 33, 255
; lad.png
defb 44, 65, 63, 63, 63, 37, 224, 255
>
Requires the .NET framework 3.5. Sorry!
Boray
Musical Smurf
Posts: 4064
Joined: Mon May 03, 2004 10:47 am

Re: PNGtoUDG

Post by Boray »

Kweepa wrote: Requires the .NET framework 3.5. Sorry!
What are you sorry about? It's a privilege to have .NET installed! :wink:
PRG Starter - a VICE helper / Vic Software (Boray Gammon, SD2IEC music player, Vic Disk Menu, Tribbles, Mega Omega, How Many 8K etc.)
User avatar
Mike
Herr VC
Posts: 4816
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Post by Mike »

I used a similar program to create the UDG data for MINIPAINT, even though I did the design in MS Paint as *.bmp, and then a conversion in IrfanView to *.pgm, so my image library (see 'image.c' and 'image.h' here) could process the bitmap:

Image

The grey/white checkerboard pattern shows the 8x8 character bounding boxes. Then this C program converts it into EQUB directives for the inline assembler of HI BASIC:

Code: Select all

#include <stdio.h>
#include <stdlib.h>
#include "image.h"

int main(int argc, char *argv[])
{
  IMAGE *image=image_load("status");
  FILE *stream=fopen("result.txt","w");
  int byte[8],x,x2,y,y2;

  for(y=0; y<4; y++)
    for(x=0; x<14; x++)
    {
      for(y2=0; y2<8; y2++)
      {
        byte[y2]=0;
        for(x2=0; x2<8; x2++) byte[y2]=2*byte[y2]+(b_pixel(image,x*8+x2,y*8+y2)<128);
      }
      fprintf(stream," EQUB %3d:EQUB %3d:EQUB %3d:EQUB %3d:EQUB %3d:EQUB %3d:EQUB %3d:EQUB %3d\n",
                       byte[0], byte[1], byte[2], byte[3], byte[4], byte[5], byte[6], byte[7]);
    }
  exit(EXIT_SUCCESS);
}
It would have been a much hairier task to design this in a normal character editor, let alone squared paper. :P

Anyway, this thread should go into 'Emulation and Cross-Development'. Could one of the mods please move it to there?
Post Reply