I search programs to convert PC graphs -> MSX.

Page 2/3
1 | | 3

By Samor

Prophet (2098)

Samor's picture

21-03-2007, 14:22

I remember an old tool that could read BMP files on MSX, and convert them... probably not as good as these solutions, though...

By ro

Scribe (4421)

ro's picture

21-03-2007, 15:26

didn't MSD build such softs?

By wolf_

Ambassador_ (9876)

wolf_'s picture

21-03-2007, 15:46

msd..? MSD..? The same msd who only codes stuff for screen 0 and g9k? That 'msd'? Tongue

By Sd-Snatcher

Hero (582)

Sd-Snatcher's picture

23-03-2007, 00:51

Now im working on this unoptimized code:

#include <stdio.h>
#include <msx/msx.h>
#include <ctype.h>
#include <string.h>

static FCB file;

static void set_name( FCB *p_fcb, const char *p_name ) {
	int i, j;

	memset( p_fcb, 0, sizeof(FCB) );
	for( i = 0; i < 11; i++ ) {
		p_fcb->name[i] = ' ';
	}
	for( i = 0; (i < 8) && (p_name[i] != 0) && (p_name[i] != '.'); i++ ) {
		p_fcb->name[i] = toupper( p_name[i] );
	}
	if( p_name[i] == '.' ) {
		i++;
		for( j = 0; (j < 3) && (p_name[i + j] != 0) && (p_name[i + j] != '.'); j++ ) {
			p_fcb->ext[j] = toupper( p_name[i + j] );
		}
	}
}

void pset(unsigned char x, unsigned char y, unsigned char color)
{
	vpoke((y*256)+x,color);
}

void readbmp(unsigned char xoffset, unsigned char yoffset, const char *p_name)
{
	unsigned long x,xsize;
	unsigned long y,ysize;
	
	unsigned long cont;
	
	int r;
	
	unsigned char buffer[256];
	file.drive_no = 0;
	file.current_block = 0;
	
	set_name( &file, p_name );

	if( fcb_open( &file ) != FCB_SUCCESS )
	{
		puts( "Failed: fcb_open()" );
/*		return 0;*/
	}

	r = fcb_read( &file, buffer, 18 ); /*header 1*/

	r = fcb_read( &file, buffer, 4 );
	xsize=buffer[0];
	xsize+=buffer[1]*256;
	xsize+=buffer[2]*256*256;
	xsize+=buffer[3]*256*256*256;

	r = fcb_read( &file, buffer, 4 );
	ysize=buffer[0];
	ysize+=buffer[1]*256;
	ysize+=buffer[2]*256*256;
	ysize+=buffer[3]*256*256*256;
	

	r = fcb_read( &file, buffer, 256 ); /*header 2*/
	r = fcb_read( &file, buffer, 256 ); /*header 2*/
	r = fcb_read( &file, buffer, 256 ); /*header 2*/
	r = fcb_read( &file, buffer, 256 ); /*header 2*/
	r = fcb_read( &file, buffer, 29 );  /*header 2*/

	cont=((xsize/4)+1)*4;

	for (y=ysize; y>0 ; y--)
	{
		if (cont==xsize+4)
		{
			r = fcb_read( &file, buffer, xsize );
			if( r == 0 ) break;
		}
		else
		{
			r = fcb_read( &file, buffer, cont );
			if( r == 0 ) break;
		}
	   
		for (x=0; (x

Can be compiled with SDCC.

Can be used to load bmp files directly. Wink ... in screen 8

By Hecatonchire

Supporter (11)

Hecatonchire's picture

23-03-2007, 04:31

Wolf,
I am interested by the techniques which you use to make the reduction of pallet (or quantization). Can you say some more to us on this subject ?.

By Sd-Snatcher

Hero (582)

Sd-Snatcher's picture

23-03-2007, 11:29

This code is only for 8 bit bmp, im using it to make skinnable games.

By wolf_

Ambassador_ (9876)

wolf_'s picture

23-03-2007, 11:53

Actually it's not optimal yet, currently I must compare an image to a ready-made palette, so it's not like in photoshop where you can say how many colors you want to use and then photoshop finds the most relevant/important colors to rebuild the image with only those colors. Atm I've also included 3 C64 palettes.. (3, as no-one seems to be able to extract the right palette from the machine, so I grabbed palettes from various sources).
One can toggle individual colors on/off when matching the defined palette with an image. So, if I have a blue'ish image I want to convert to MSX1, then I can specify only to use the colors 0,4,5,7,14,15. The algo is just a typical colormatcher.

You might find the sourcecode of bmp2msx interesting, it's just there for download (see link on page 1).

Here is also some more information!

Chances are this texgen will produce output for new 4motion stuff (but then an upgraded version with more features!).

btw, for black/white there's hardly any palette matching one needs to do, just posterise is enough.

By SLotman

Paragon (1236)

SLotman's picture

23-03-2007, 16:12

I personally do all my graphics in Paint Shop Pro (7, didnt like later releases) - If for scr5 I just reduce colour depth to 16 (there are two different ways the programs allows you to do that, both with and without dither); if scr8, I just load an scr8 pal I have... Then I just use the image converter on MSXPad to create the raw file for me Smile

For MSX1 I try to color everything in 8x8/2 colors line, with the help of an 8x8 grid using an MSX1 pal, then I just throw the image on MSXViewer to see if I don't missed anything and to convert it to "bloadable" SCR2 file :)

By ARTRAG

Enlighted (6506)

ARTRAG's picture

23-03-2007, 16:40

The color conversion should follow the standard rules of vector quantization.
The the space of colors can be (R,G,B) and the distance the standard eulidean mean squere error.

You select the number of colors you want in the final image (e.g. 16), and
apply K-means algorithm that is the simpliest way to get a good result:

http://en.wikipedia.org/wiki/K-means_algorithm

Go here for a very ad hoc K-means ;)

http://www.leet.it/home/lale/joomla/component/option,com_wrapper/Itemid,50/

LOL!

By ARTRAG

Enlighted (6506)

ARTRAG's picture

23-03-2007, 18:34

About

http://www.leet.it/home/lale/joomla/component/option,com_wrapper/Itemid,50/

the demo in Java is great!!!

BTW
If you have a fixed palette, (e.g. the MSX1 palette), you can use the minimum distance
criterium in (R,G,B) space without any update of the centroids.

Page 2/3
1 | | 3