Log inRegister an accountBrowse CSDbHelp & documentationFacts & StatisticsThe forumsAvailable RSS-feeds on CSDbSupport CSDb Commodore 64 Scene Database
You are not logged in - nap
CSDb User Forums


Forums > C64 Coding > Kickassembler - Converting .PNG to Koala
2012-02-21 15:04
TWW

Registered: Jul 2009
Posts: 541
Kickassembler - Converting .PNG to Koala

Hey fellow hackers.

I wanted to write a converter in Kickassembler which can take any .PNG MC Bitmap screenshot from VICE (Then I don't need to worry about the RGB values since they are known) and convert into raw data you can use in your productions.

This is the way I imagine doing it:

#1 - Determin the background collor based on the most used collor in the picture
#2 - Verify there is no 4x8 block containing more than 3 collors+BG
#3 - Convert each 4x8 block afterwards and write the data into 3 lists (1 for BMP data, 1 for Charcollors and 1 for collmem).
#4 - Add BG collor at the end :-)

I'm looking for improvement comments on this or maybee I need to revise the way I think about this?
 
... 37 posts hidden. Click here to view all posts....
 
2012-02-22 11:37
algorithm

Registered: May 2002
Posts: 702
What magervalp said. No need for any conversion if the image is displayed in vice. Use the d021 color from there and save the data.

bank io
bsave "d800loc" 0 $d800 dbe7
bsave "inkpaploc" 0 $0400 $07e7 ;varies of course
bsave "gfx" 0 $2000 $3f3f ; varies of course
bsave "d021loc" 0 $d021 d021
2012-02-22 11:44
kmeg
Account closed

Registered: Sep 2003
Posts: 5
If there is need for that I can update this tools The CCS64 Gfx Rippers to support Vice...
2012-02-22 12:23
Cruzer

Registered: Dec 2001
Posts: 1048
Quote: What magervalp said. No need for any conversion if the image is displayed in vice. Use the d021 color from there and save the data.

bank io
bsave "d800loc" 0 $d800 dbe7
bsave "inkpaploc" 0 $0400 $07e7 ;varies of course
bsave "gfx" 0 $2000 $3f3f ; varies of course
bsave "d021loc" 0 $d021 d021


This is supposed to be easier than taking a screenshot?
2012-02-22 12:24
JackAsser

Registered: Jun 2002
Posts: 1989
Use Enthusi's excellent vice snapshot grapper. Simply take a VICE snapshot (not screenshot) and use the utility to extract what's on screen.

Vice Snapshot Grabber 4.2
2012-02-22 12:27
Flavioweb

Registered: Nov 2011
Posts: 447
isn't already in vice a menu option to 'save multimedia file' for export pictures in koala format?
2012-02-22 14:25
algorithm

Registered: May 2002
Posts: 702
Quote: This is supposed to be easier than taking a screenshot?

Certainly not easier than that, but easier than going through conversion processes of finding background color, checking 4x8 blocks etc.
2012-02-22 15:26
TWW

Registered: Jul 2009
Posts: 541
I think we are getting a bit off track here.

I want to make a macro which converts a 320x200 picture on the PC (which follows the multicollor limitation of bitmap gfx on the C64) directly into my code in Kickassembler.

I want to use the script language supplied by the powerfull Kickassembler to do it and not a 3rd party tool which will add a step to the process.

I know it is possible but I wanted to get some ideas before diving into the matter.

After giving it some thought, i came up with something like this:

- Fetch all "4 collors" 4x8 blocks store them into a list (ignore blocks with 3, 2 or 1 collor(s)).
- repeat for all 1000 blocks and make a new list for each 4 coll block. (there is probably some nice way to store 2D lists (hastables?) which does this effectivly, still figguring this part out).
- Find the common collor in the stored blocks
- Start converting blocks to 2 bit pixel-data while setting the BG to #%"00" when it is encounterred.
- Store the colldata into seperate lists while each block is converted
- memfill the bmp/coll-data where you want it(set by the macro call).

Later if you modify the picture a little bit or change it with another one, just copy the .PNG file and the assembler does the rest.
2012-02-22 15:43
chatGPZ

Registered: Dec 2001
Posts: 11114
<Post edited by chatGPZ on 22/2-2012 20:24>

Quote:
Groepaz's approach can also fail, if there are no blocks using 4 colors at the same time.

ofcourse, as a first step you must count colors per cell and then sort the cells by how many colors are in them :)

edit: thats nonsense ofcourse. if there is no block with 4 colors then you can pick whatever bg color you like =P

that said, i would also suggest to use a makefile and a small external tool. maybe even hack it up yourself (because it is trivial, and didnt we all? =P). doing something like that in the assembler seems a bit pointless, wrong tool for the job, etc.
2012-02-22 19:09
Slammer

Registered: Feb 2004
Posts: 416
I would use this approach (pseudocode):
   backgrounColorSet =  {color0, color1, .., color15}
   for all blocks
      if (block has 4 colors)
         remove all but the 4 colors from the backgroundColorSet

Kick Assembler doesn't support sets yet, but you can use the keys in a hash table as a set and afterwards use 'hashtable.keys()' to get the possible background colors.
2012-02-22 19:50
Cruzer

Registered: Dec 2001
Posts: 1048
Slammer: Guess a list of 16 booleans indicating whether the colors are candidates for bg colors would do the trick. For each 4-color block, set the 12 others to false.
Previous - 1 | 2 | 3 | 4 | 5 - Next
RefreshSubscribe to this thread:

You need to be logged in to post in the forum.

Search the forum:
Search   for   in  
All times are CET.
Search CSDb
Advanced
Users Online
Stainless Steel/F4CG
fenz/SCC
zscs
HOL2001/Quantum
Apollyon/ALD
Brittle/Dentifrice^(?)
Guests online: 141
Top Demos
1 Next Level  (9.8)
2 Mojo  (9.7)
3 Coma Light 13  (9.7)
4 Edge of Disgrace  (9.6)
5 Comaland 100%  (9.6)
6 No Bounds  (9.6)
7 Uncensored  (9.6)
8 Wonderland XIV  (9.6)
9 Memento Mori  (9.6)
10 Bromance  (9.5)
Top onefile Demos
1 It's More Fun to Com..  (9.7)
2 Party Elk 2  (9.7)
3 Cubic Dream  (9.6)
4 Copper Booze  (9.5)
5 TRSAC, Gabber & Pebe..  (9.5)
6 Rainbow Connection  (9.5)
7 Wafer Demo  (9.5)
8 Dawnfall V1.1  (9.5)
9 Quadrants  (9.5)
10 Daah, Those Acid Pil..  (9.5)
Top Groups
1 Oxyron  (9.3)
2 Nostalgia  (9.3)
3 Booze Design  (9.3)
4 Censor Design  (9.3)
5 Crest  (9.3)
Top Swappers
1 Derbyshire Ram  (10)
2 Jerry  (9.8)
3 Violator  (9.8)
4 Acidchild  (9.7)
5 Starlight  (9.6)

Home - Disclaimer
Copyright © No Name 2001-2024
Page generated in: 0.045 sec.