Graphic/Picture File Formats on VIC-20

Basic and Machine Language

Moderator: Moderators

User avatar
Mike
Herr VC
Posts: 4841
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Post by Mike »

Fine! :) I did mention Brickshop here in another thread.

Michael
User avatar
hawk
Vic 20 Afficionado
Posts: 342
Joined: Mon Jun 20, 2005 7:32 pm

Post by hawk »

I'm still playing around with these ideas, but I've had some problems with the latest build of ppmtovic. Processing the same image files with the same settings results in some corruption of the output image.

Also, if I specify only to use certain colours, it stll uses some others (only black I think). I haven't had a chance to nail down the problems yet, but in the meantime, check this out...

http://www.ticalc.org/pub/win/graphics/

Have a look at the files

http://www.ticalc.org/pub/win/graphics/istudio.zip
http://www.ticalc.org/pub/win/graphics/istudio2.zip

Although it's only working in greyscale, and the final output isn't in the correct format, it gives some good ideas about what can be achieved.

At the same site there are also some good character/font editors that do output in a format useable for the VIC.
a1bert
Vic 20 Dabbler
Posts: 96
Joined: Mon Jan 23, 2006 12:49 am

Post by a1bert »

hawk wrote:Processing the same image files with the same settings results in some corruption of the output image.
You can E-mail me the image file and the commandline and I can take a look.

-Pasi
User avatar
hawk
Vic 20 Afficionado
Posts: 342
Joined: Mon Jun 20, 2005 7:32 pm

Post by hawk »

Just posting a followup to this thread.

As it turned out, the corruption I was getting was being caused by me using an interim version of the program. When I grabbed the latest, it fixed my problems.

Pasi, do you have the source for the assembler versions of the display code that gets added to the output file? If so, is it possible to grab a copy? I'm looking through it to see how it works. I'm also considering a program which loads the image programs and displays them via windows with the possibility of extending it to include editing.

Thanks,
Hawk.
a1bert
Vic 20 Dabbler
Posts: 96
Joined: Mon Jan 23, 2006 12:49 am

Post by a1bert »

hawk wrote:Pasi, do you have the source for the assembler versions of the display code that gets added to the output file?
There are several versions with slightly differing specs in the VIMM and VIMMII source code packages, and I just uploaded the version used by the ppmtovic to http://www.iki.fi/a1bert/Dev/vicgfx/fullpic.asm (but there is no link to it in the Vicgfx page).
hawk wrote:I'm looking through it to see how it works. I'm also considering a program which loads the image programs and displays them via windows with the possibility of extending it to include editing.
The VIC20 viewer "simply" changes all of the three multicolor colors each rasterline, and switches video matrix every 8 lines to switch the color memory to get 8x8-pixel (well, 4x8 in multicolor) color memory resolution with 16-line characters.

If you want to make a display program, check the newest version of victoppm.c. It already handles both multicolor and hires, and also mixed-mode pictures. There is not yet a program to generate those but the format now allows it.

-Pasi
User avatar
hawk
Vic 20 Afficionado
Posts: 342
Joined: Mon Jun 20, 2005 7:32 pm

Post by hawk »

Pasi, I've made a small change to ppmtovic to assist with my lastest experiments.

It now allows some or all of the colours to be initialised, using the -i option, rather than always initialising all the colours.

Code: Select all

ie.  -i///1 (white background)
This allowed me to specify a bacground colour which would always be honoured, and still have the program work out the forground colours.

Code: Select all

	case 'i':
	    x++;
	    if (argv[i][x]!='/')
	      c0 = (atoi(argv[i]+x) /*& 15*/);
	    while(argv[i][x]>='0' && argv[i][x]<='9')
	      x++;
	    if(argv[i][x]=='/') {
	      x++;
	      if (argv[i][x]!='/')
	        c1 = (atoi(argv[i]+x) /*& 15*/);
	      while(argv[i][x]>='0' && argv[i][x]<='9')
	        x++;
	      if(argv[i][x]=='/') {
	        x++;
	        if (argv[i][x]!='/')
	          c2 = (atoi(argv[i]+x) /*& 15*/);
              while(argv[i][x]>='0' && argv[i][x]<='9')
                x++;
	        if(argv[i][x]=='/') {
	          x++;
	          if (argv[i][x]>='0' && argv[i][x]<='9')
	            c3 = (atoi(argv[i]+x) /*& 15*/);
	          while(argv[i][x]>='0' && argv[i][x]<='9')
	            x++;
	        }
	      }
	    }
       x--;
	    break;
Would you like to roll this change into the baseline program?

--Hawk

Edit
PS. I tried to get the latest version of victoppm.c, but it appears to be the same as the old version, ie. doesn't handle all the new modes.

Thanks.
a1bert
Vic 20 Dabbler
Posts: 96
Joined: Mon Jan 23, 2006 12:49 am

Post by a1bert »

hawk wrote:It now allows some or all of the colours to be initialised, using the -i option, rather than always initialising all the colours.
Well, you could've used 255 for not used.. :-)
hawk wrote: PS. I tried to get the latest version of victoppm.c, but it appears to be the same as the old version, ie. doesn't handle all the new modes.
Strange. When I convert files with ppmtovic, victoppm can convert them back correctly, whether I run ppmtovic with or without -H.
But, victoppm assumes a file without the viewer, so that may be your problem?

-Pasi
User avatar
hawk
Vic 20 Afficionado
Posts: 342
Joined: Mon Jun 20, 2005 7:32 pm

Post by hawk »

a1bert wrote:Well, you could've used 255 for not used.. :-)
Oops...I hadn't picked up the subtleties of that. :oops:
a1bert wrote:Strange. When I convert files with ppmtovic, victoppm can convert them back correctly, whether I run ppmtovic with or without -H.
But, victoppm assumes a file without the viewer, so that may be your problem?
I hadn't realised that it was converting the file without the viewer, but from looking at the code (on you web page) it appears to only handle 100x160.

I'm attempting to write a windows program that will read in, identify, and display the file appropriately.

--Hawk
a1bert
Vic 20 Dabbler
Posts: 96
Joined: Mon Jan 23, 2006 12:49 am

Post by a1bert »

hawk wrote:from looking at the code (on you web page) it appears to only handle 100x160.
Victoppm handles "100x160" multicolor, but it actually outputs 300x160 to the ppm file to approximate the VIC-I pixel aspect ratio. Thus, multicolor pixels become 3x1 square pixels, and hires pixels become either 2x1 or 1x1 (1.5x1 on average) square pixels. The decision is done on a color-cell basis, thus you can mix multicolor and hires cells in the data file and the output looks correct.

But, as I said, victoppm doesn't try to detect files with viewer code attached, and that should be improved.

-Pasi
User avatar
ral-clan
plays wooden flutes
Posts: 3702
Joined: Thu Jan 26, 2006 2:01 pm
Location: Canada

Post by ral-clan »

Can anyone compile a version of "ppmtovic" to run on an Intel Windows machine or Amiga for me? The C source code is on A1bert's site:

http://www.cs.tut.fi/~albert/Dev/vicgfx/

...but I don't have anyway to compile it into an executable.

I want to be able to run it from a command line in Windows (or on an Amiga).

Thanks!
carlsson
Class of '6502
Posts: 5516
Joined: Wed Mar 10, 2004 1:41 am

Post by carlsson »

I uploaded some Windows binaries to my page:
http://www.cbm.sfks.se/ppm2vic/

Please remember you need to convert your source file to ASCII PPM format. It also helps a lot if you resize and crop the image before conversion. Preferrably you should shrink the source picture so it is 1/3 as wide as it is tall, i.e. corrupted dimensions. As the VIC will display every pixel at triple width (like Albert wrote above), the dimension ratio gets restored that way.

If you have difficulties and don't want to discuss them in public, you're free to ask me - I've already been informed about your business. :-D
Anders Carlsson

Image Image Image Image Image
User avatar
ral-clan
plays wooden flutes
Posts: 3702
Joined: Thu Jan 26, 2006 2:01 pm
Location: Canada

Post by ral-clan »

Thanks very much. I know my Amiga graphics software will save images as a PPM file. I am not sure if this is the same thing as and "ASCII" PPM file, but I will give it a try and if it doesn't work I'll contact you!
carlsson
Class of '6502
Posts: 5516
Joined: Wed Mar 10, 2004 1:41 am

Post by carlsson »

From the good old days of xv and Solaris, I remember the portable pixmap format (PPM) was available in two versions: one ASCII version where each RGB pixel was specified as three decimal values, and one binary version where each pixel value was stored as three bytes.
Anders Carlsson

Image Image Image Image Image
User avatar
ral-clan
plays wooden flutes
Posts: 3702
Joined: Thu Jan 26, 2006 2:01 pm
Location: Canada

Post by ral-clan »

carlsson wrote:Please remember you need to convert your source file to ASCII PPM format....From the good old days of xv and Solaris, I remember the portable pixmap format (PPM) was available in two versions: one ASCII version where each RGB pixel was specified as three decimal values, and one binary version where each pixel value was stored as three bytes.
Interesting. When I save a PPM as an ASCII PPM in Irfanview, PPMTOVIC says it can't handle that file type. But when I save it as a Binary PPM with Irfanview, it processes it just fine.
User avatar
hawk
Vic 20 Afficionado
Posts: 342
Joined: Mon Jun 20, 2005 7:32 pm

Post by hawk »

ral-clan wrote:Interesting. When I save a PPM as an ASCII PPM in Irfanview, PPMTOVIC says it can't handle that file type. But when I save it as a Binary PPM with Irfanview, it processes it just fine.
If you look though the source, you'll see that ppmtovic only handles the P6 format of the PPM file, which uses binary encoding. The header is still ASCII, but the image data is binary.
Post Reply