Minigrafik GIMP Plugin Development

You need an actual VIC.

Moderator: Moderators

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

Minigrafik GIMP Plugin Development

Post by hawk »

Hi All,

I've been having a play with a GIMP plugin that reads Minigrafik files. I finally had some success today, and I wanted to share it with you. It took a bit of fiddling, and when the image finally appeared, it was like magic!

I've been working from the cbmplugs and have attempted to add the Vic-20 Minigrafik as a new type. In reality, I will probably extract the plugin out of the original files as a separate plugin, as I'm sure the original developer doesn't want to add Vic-20 formats to his C64 plugins. The cbmplugs has been a good place to start however.

Image

It sets the Gimp image type to indexed and sets the palette to a Vic-20 palette.
Image

At this stage I haven't got it reading the colours from the file but that's the next thing to get working. I'd also like it to be able to handle multicolour and hires characters in the same file.

The ultimate goal is to allow GIMP to write Minigrafik files directly, reading them is just the first stage in learning how to program GIMP plugins. A great option would be to perform automatic conversion of images to MG format using a plugin, however that's a long way off at the moment.
Last edited by hawk on Mon Jun 03, 2013 7:01 am, edited 1 time in total.
rhurst
Omega Star Commander
Posts: 1369
Joined: Thu Jan 31, 2008 2:12 pm
Website: https://robert.hurst-ri.us
Location: Providence, RI
Occupation: Tech & Innovation

Post by rhurst »

Now _that_ is simply awesome, keep up the development work on that!! 8)
Any technology distinguishable from magic is insufficiently advanced.
https://robert.hurst-ri.us/rob/retrocomputing
User avatar
hawk
Vic 20 Afficionado
Posts: 342
Joined: Mon Jun 20, 2005 7:32 pm

Post by hawk »

Thanks for the encouragement Rob.

I finally got it correctly decoding the colour map today.

ImageImage

The next step will be to have it correctly decode multi-colour and hires graphics.
Last edited by hawk on Mon Jul 14, 2014 5:03 am, edited 1 time in total.
User avatar
Kweepa
Vic 20 Scientist
Posts: 1314
Joined: Fri Jan 04, 2008 5:11 pm
Location: Austin, Texas
Occupation: Game maker

Post by Kweepa »

Yes, this will be awesome!
User avatar
orion70
VICtalian
Posts: 4337
Joined: Thu Feb 02, 2006 4:45 am
Location: Piacenza, Italy
Occupation: Biologist

Post by orion70 »

Can't wait for this! Thank you! :)
User avatar
Mike
Herr VC
Posts: 4816
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Re: Minigrafik GIMP Plugin Development

Post by Mike »

Hi!

It's nice to see some independent development regarding the MG picture file format. :D
hawk wrote:It sets the Gimp image type to indexed and sets the palette to a Vic-20 palette.
Image
The target platform (i.e. the VIC-20 itself) will of course impose its own version of the palette, but this one looks quite wrong. Especially Light Orange and Light Red should have nearly the same luminance. Also, the palettes of PAL and NTSC VIC-20s are different. Here are two examples, which darkatx and I worked out after photographing test images on real hardware:

---------- PAL ------------------- NTSC ---------
Image Image

Too bad one can't really tell the light versions of Orange, Red and Purple apart on NTSC. :(
A great option would be to perform automatic conversion of images to MG format using a plugin, however that's a long way off at the moment.
The big question would be how you are going to handle source images which do not strictly conform to the hardware restrictions as they are modelled by the format.
User avatar
hawk
Vic 20 Afficionado
Posts: 342
Joined: Mon Jun 20, 2005 7:32 pm

Post by hawk »

Thanks for the info on the palettes Mike. I'm not really using the colours as such yet, just displaying existing images using the defined palette. So I can create a new palette from the colours you have given me. I was unsure of which palette colours to use, so I Googled and found them on a Wiki page. I'll update my GIMP palettes with your samples.

The encoding of MiniGrafik files is much more difficult than displaying them. I have considered loooking at how many colours are use in a character block and then approximating. I have also considered just using the first colour that I come across for a character block, and using that. There are many possibilities, and handling Hires and Multi-colour at the same time is even more difficult.

I considered using layers to indicate the settings of character blocks also.

School is back now, so development has halted for a while. I currently have it correctly loading and displaying an image that includes colours and also a mixture of multi-colour and hires graphics. The code is very messy and needs a lot of clean up, but it is working.
PhilRanger
Vic 20 Hobbyist
Posts: 143
Joined: Thu Aug 25, 2011 10:04 am

Re: Minigrafik GIMP Plugin Development

Post by PhilRanger »

hawk wrote:The ultimate goal is to allow GIMP to write Minigrafik files directly, reading them is just the first stage in learning how to program GIMP plugins.
I got drool all over my keyboard now. Who do I send the bill to? :roll:
Phil Ranger
-------------
"Don't eat the trees 2" for the VIC 20 : http://www.box.net/shared/u398kj0nr0lkauzm1k67
on line: http://www.mdawson.net/vic20chrome/vic2 ... otrees.prg
User avatar
Ghislain
Realms of Quest
Posts: 1279
Joined: Sun Aug 08, 2004 12:54 am

Post by Ghislain »

I'm a big fan of putting splash screens in games :mrgreen:
"A slave is one who waits for someone to come and free him." -- Ezra Pound
User avatar
Mike
Herr VC
Posts: 4816
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Post by Mike »

Here I have another MG picture to test your GIMP plugin with: a Currywurst dish. ;)

Image
(download)

Greetings,

Michael
Last edited by Mike on Thu Feb 20, 2014 5:24 pm, edited 1 time in total.
User avatar
hawk
Vic 20 Afficionado
Posts: 342
Joined: Mon Jun 20, 2005 7:32 pm

Post by hawk »

Updating some links to files so thought I'd add this one.

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

Post by Mike »

hawk wrote:Updating some links to files so thought I'd add this one.
Some time ago I posted a *.d64 with some other mixed-mode pictures in the thread about the MG batch suite (link).

Does GIMP allow for a display with non-square pixel aspect ratio? After all, the real resolution of MG pictures is 160x192, not 320x192 - the latter which is the result of simple pixel doubling to approximate the non-square VIC pixels. But in reality, the aspect ratio is not 2:1, rather more like ~1.67:1 (or 5:3 in small integers) for PAL and ~1.5:1 for NTSC.

In my screenshots, I use IrfanView to correct the aspect ratio for these fractional values.
User avatar
hawk
Vic 20 Afficionado
Posts: 342
Joined: Mon Jun 20, 2005 7:32 pm

Aspect Ratio of GIMP Pixels

Post by hawk »

With the current viewer I'm just manually making the aspect ratio 2:1 by painting each pixel twice. A bit of a cludge.

A quick bit of investigation tells me that I should be able to set the image resolution at the time of creation and then I can set it appropriately.

Next time I'm having a play I might see if I can get that going. It would certainly make it easier to edit and then write out an image, as I wouldn't have to worry about ensuring that only whole pixels are modified.

My new resolutions would be something like

120 x 72 ppi for PAL
108 x 72 ppi for NTSC

BTW, is there an easy way to extract files from a D64 image?
User avatar
hawk
Vic 20 Afficionado
Posts: 342
Joined: Mon Jun 20, 2005 7:32 pm

Post by hawk »

OK, so I couldn't wait to test it. :D

It turns out that you can display non-square pixels. You have to set the resolution of the pixels at creation, and I got the orientation wrong.

72 x 120 ppi for PAL.

You also have to turn the "Dot for Dot" setting OFF in the "View" menu so that the image appears at its correct aspect ratio.

Now to modify my code so that it only outputs one pixel per pixel (so to speak).
User avatar
hawk
Vic 20 Afficionado
Posts: 342
Joined: Mon Jun 20, 2005 7:32 pm

Post by hawk »

Image

Here's the updated image.

As you can see from this image, it is now the correct size for a Minigrafik image (160x192) and the pixels are no longer square.

The aspect ratio can be changed by changing the x and y resolutions of the image.

The decoding and display format is correctly picking up the mixture of multicolour and hires character blocks in the image.

Mike, do you have an algorithm that automatically determines which parts of an image can be hires, and which parts would be better off multicolour when converting to Minigrafik format?
Post Reply