Minigrafik GIMP Plugin Development

You need an actual VIC.

Moderator: Moderators

User avatar
Pedro Lambrini
Vic 20 Scientist
Posts: 1132
Joined: Mon Dec 01, 2008 11:36 am

Post by Pedro Lambrini »

This is really interesting. Asking as an ignoramus, does this mean that eventually we'll be able to draw VIC compatible pictures in GIMP and then transfer them to the real hardware? Just looking for clarification. :)
"...That of the Eastern tribe being like a multitude of colours as if a rainbow had settled upon its brow..." Daniels 1:3
User avatar
darkatx
Vic 20 Afficionado
Posts: 470
Joined: Wed Feb 04, 2009 2:17 pm
Location: Canada

Post by darkatx »

Pedro Lambrini wrote:This is really interesting. Asking as an ignoramus, does this mean that eventually we'll be able to draw VIC compatible pictures in GIMP and then transfer them to the real hardware? Just looking for clarification. :)
That's what it looks like to me... :)
Learning all the time... :)
User avatar
hawk
Vic 20 Afficionado
Posts: 342
Joined: Mon Jun 20, 2005 7:32 pm

Post by hawk »

Being able to edit and save images in a VIC-20 format would be the ultimate goal, however I'm still getting my head around GIMP Plug-ins.

I haven't yet learned how to save a file in VIC-20 format yet. That will be my next challenge.

My initial goal was to be able to open an image file, select a portion of it in the appropriate aspect ratio and use the GIMP's functions to convert to a VIC-20 MiniGrafik format.

Initially I would be relying on Mike's algorithms that he uses to convert from grey scale to MiniGrafik. One of my current challenges is to determine whether I can associate additional data with the GIMP image data.

I'll keep chipping away and see where it gets me.
User avatar
akator
Vic 20 Afficionado
Posts: 327
Joined: Wed Apr 14, 2010 6:01 pm

Post by akator »

This GIMP plugin is a great idea :)
User avatar
Mike
Herr VC
Posts: 4816
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Post by Mike »

This answer's quite late, and I am not being quite sure, whether the project has been continued in the meantime, but nonetheless ...
hawk wrote:I haven't yet learned how to save a file in VIC-20 format yet. That will be my next challenge.

My initial goal was to be able to open an image file, select a portion of it in the appropriate aspect ratio and use the GIMP's functions to convert to a VIC-20 MiniGrafik format.
The MG picture file format has been thoroughly defined in Appendix D of the MINIPAINT manual, which I published nearly two years ago. The total file size is 4097 bytes. The load address ($10F1) and the contents of the immediately following BASIC stub (13 bytes), as well as the display routine at the end of the file (120 bytes) are considered immutable.

Of course one can take a MG file, and transform it into a loader picture for example - which I just did a few days before for the loader of VIC Doom. Such a changed file will still display the intended screen, but it is not anymore a valid MG picture file. MINIPAINT performs some simple checks to guard against 'invalid' files, and will just refuse to load them.
Pedro Lambrini wrote:This is really interesting. Asking as an ignoramus, does this mean that eventually we'll be able to draw VIC compatible pictures in GIMP and then transfer them to the real hardware? Just looking for clarification. :)
If you are looking for a means to craft hires pictures for the VIC-20 on the PC, you're probably overlooking the most obvious option: you can take MINIPAINT within VICE, and start either from a blank canvas (admittedly difficult unless you are a pixel artist), or otherwise maybe take some line-art created on the PC, import it with the MG batch suite and refine it - again! - within MINIPAINT.

It is quite possible to devise a paint program, which natively runs on the PC and emits MG conformant files - similar feats have been done for the hires graphics on the C64 with the PC-hosted Project One, Timanthes, and other tools. Any such program for VIC-20 pictures would have to measure against MINIPAINT, which has at least some things on its favour: hosted on the target, one can immediately judge the video output - the hardware restrictions of the underlying graphics mode are guaranteed to be enforced correctly, as a matter of course - and, it's not just an isolated tool, it comes with MINIGRAFIK as development platform. :)
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?
Just a few days after you started this thread, I could successfully transfer some critical parts of the VFLI image converter to the MG screen format. And yes, that algorithm can choose between hires and multi-colour on a per-attribute-cell basis.

Unlike many other programs I published for the VIC-20, I decided to keep the source closed for both the VFLI converter and the derived MG converter. Sorry.
User avatar
darkatx
Vic 20 Afficionado
Posts: 470
Joined: Wed Feb 04, 2009 2:17 pm
Location: Canada

Post by darkatx »

Mike wrote:If you are looking for a means to craft hires pictures for the VIC-20 on the PC, you're probably overlooking the most obvious option: you can take MINIPAINT within VICE, and start either from a blank canvas (admittedly difficult unless you are a pixel artist), or otherwise maybe take some line-art created on the PC, import it with the MG batch suite and refine it - again! - within MINIPAINT.
I did just that for my Spidey vs Doc Ock pic and it turned out great and once I figured out the interface - it made for a smooth transition. :)
Learning all the time... :)
User avatar
darkatx
Vic 20 Afficionado
Posts: 470
Joined: Wed Feb 04, 2009 2:17 pm
Location: Canada

Re: Minigrafik GIMP Plugin Development

Post by darkatx »

I really could have used this plugin right about now.

Finally making headway into my graphics WIP and its a bit tedious. The main thing is I desire is to use my tablet to do my graphics in...if it was just a static image then I'd use Mike's Minigrafik and be happy...which I'll definitely end up doing for the title screen.

Come to think of it...I may very well be using Minigrafik for half of my project to overcome the character screen dimension issues I'm having but at least I'll be able to view the entire thing on the hardware itself.
Learning all the time... :)
User avatar
hawk
Vic 20 Afficionado
Posts: 342
Joined: Mon Jun 20, 2005 7:32 pm

Re: Minigrafik GIMP Plugin Development

Post by hawk »

It has been quite a while since I've had time to develop this plugin further. I was quite surprised at the interest in my initial trials.

I sense from Mike that his preference is to have Minigrafik development done using Minipaint, and I can respect that. However, the sort of development I'm looking at is less original creation, and more conversion of existing images. The images that I would envisage working from may not even fit in VIC-20 memory. Being able to select a portion of a file in correct VIC-20 ratio and import it using the plugin, doing any re-sampling required to get them to the required resolution, taking into account the aspect ratio of the pixels.

I've attached a screenshot of the original program I came across that got me thinking about all this. What I really liked about this program is that it shows the original file, the greyscale converted file and the output file, updating the output file after any modification to the contrast or brightness is done. This program doesn't even try to perform any dithering, it just uses thresholding. The GIMP would also potentially add multiple dithering techniques to choose from depending on the type os source image.

Once an image was in the final VIC-20 format, it could be touched up manually and then saved.

One of the problems that always brings me to a standstill when it comes to converting an image to VIC-20 format, is that there are just so many variables and possibilities. Each character block can be multicolour or hi-res...when is it better to use one or the other? If only doing grey scale, as Mike's original converter did, it's not so bad.

If the number of interruptions I've had just trying to compose this post is any indication, I'm unlikely to get much more progress on this in the near future, however, every now and then I use it as a brain puzzle and try to chip away at my misunderstandings, even if I don't get any code developed.
Attachments
TI-84 Image Studio Program for converting JPG files and outputting data for use in a TI-84 program.
TI-84 Image Studio Program for converting JPG files and outputting data for use in a TI-84 program.
Clipboard01.png (230.29 KiB) Viewed 3826 times
User avatar
hawk
Vic 20 Afficionado
Posts: 342
Joined: Mon Jun 20, 2005 7:32 pm

Re: Minigrafik GIMP Plugin Development

Post by hawk »

Nearly another year down the track, and still I continue to plug away at my plug-in. :lol: I thought it was time I posted an update.

I've cleaned up to code a bit and have got it correctly writing out image files (I say correctly, however I think I still have it set so that it auto loads and runs in VICE rather than the actual Minigrafik file format. That's just a couple of bytes at the start.)

At the moment it just does a simple Hi Res conversion of the original file, and I can select the foreground and background colours as a whole (not per cell).

Here's an example.
This is the file as edited in The Gimp.
GIMP wave original.png
GIMP wave original.png (101.5 KiB) Viewed 3223 times
Then I can export the file and run it in VICE.
VICE wave output.png
VICE wave output.png (86.58 KiB) Viewed 3223 times
Finally, I can reload the output file into The Gimp again.
GIMP wave output.png
GIMP wave output.png (111.31 KiB) Viewed 3223 times
The output ratio is displayed by The Gimp by turning off the Dot-to-Dot feature.

Next I'm considering doing a conversion based on Mike's original greyscale dithering of an 80x192 pixel image into a 4-colour multicolour image. That will test my ability to correctly map the colours to the palettes
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 »

:D
hawk wrote:Next I'm considering doing a conversion based on Mike's original greyscale dithering of an 80x192 pixel image into a 4-colour multicolour image. That will test my ability to correctly map the colours to the palettes
You can take the dither patterns from the DATA lines in PGM IMPORT:

Code: Select all

35 DATA 2,2, 2,2, 3,2, 3,3, 3,3, 3,3, 3,0, 0,0, 0,0, 0,0, 1,0, 1,1, 1,1
36 DATA 2,2, 2,3, 2,3, 2,3, 3,3, 0,3, 0,3, 0,3, 0,0, 0,1, 0,1, 0,1, 1,1
37 DATA 2,2, 2,2, 2,3, 3,3, 3,3, 3,3, 0,3, 0,0, 0,0, 0,0, 0,1, 1,1, 1,1
38 DATA 2,2, 3,2, 3,2, 3,2, 3,3, 3,0, 3,0, 3,0, 0,0, 1,0, 1,0, 1,0, 1,1
They have been arranged in the same way as they appear later on screen.

You should note, that MINIGRAFIK remaps the colour sources in multi-colour mode. Foreground is considered #1 regardless of hires or multi, the exterior border thus is assigned #2. This differs from how the hardware actually encodes the colour sources, which is %01 for exterior border, %10 for foreground.

That means, the dither patterns start with the exterior border colour (%01), which in this application has been fixed to be black, then assumes the auxiliary colour (%11, which is assumed to be the darker of the two intermediary colours), then through the background colour (%00, which is the lighter one of the two intermediary colours) to finally arrive at the foreground colour (%10), which is fixed to be white. The choice of background and auxiliary colour as the two intermediary colours allows to one to use any of the 16x16 = 256 possible combinations. In practice, one wouldn't use those combinations, where one of the intermediary colours either is black or white, or where those two colours are in the wrong order or have too low a contrast.

The mapping of the 256 grey intensities to the 13 dither patterns is done with the formula L' = int((24 * L + 255) / 510), which maps 0..255 to the range 0..12. The 'ends' of the intensity range, 0 and 12, only take up half the intervals than the rest. The patterns itself have been carefully chosen, so that for sufficiently slow gradients it can never happen that two colour sources of intensity I and I+2 are placed next to each other.

Looking forward to the implementation in GIMP. :)
User avatar
darkatx
Vic 20 Afficionado
Posts: 470
Joined: Wed Feb 04, 2009 2:17 pm
Location: Canada

Re: Minigrafik GIMP Plugin Development

Post by darkatx »

Looking sweet! :)
Learning all the time... :)
User avatar
hawk
Vic 20 Afficionado
Posts: 342
Joined: Mon Jun 20, 2005 7:32 pm

Re: Minigrafik GIMP Plugin Development

Post by hawk »

I now have it writing out the MiniGrafik multicolour grey scale images. No fancies for selecting colours yet.
Attachments
Screenshot - 230615.png
Screenshot - 230615.png (130.16 KiB) Viewed 2916 times
Post Reply