Tiles

Hi guys,
I have a little problem.
I would like to make a program to cut tiles from a bitmap.
So, I created two SDL_Surface, the first is bitmap and the second is tiles.

Now I want to copy a part of bitmap into tiles… but I couldn’t do it

Following you will find my code… tnx

SDL_Surface *bitmap, *tiles;
SDL_Rect src, dst;

bitmap = SDL_LoadBMP(argv[1]);

src.x = 0;
src.y = 0;
src.h = 32;
src.w = 32

dst = src;

SDL_BlitSurface(bitmap, &src, tiles, &dst);

SDL_SaveBMP(tiles, file);

Following you will find my code… tnx

“tiles” is an unset pointer! Yikes!

You need to use SDL_CreateRGBSurface() or somesuch!

-bill!On Sat, Mar 22, 2003 at 07:28:39PM +0100, Salvo Di Fazio wrote:

SDL_Surface *bitmap, *tiles;
SDL_Rect src, dst;

bitmap = SDL_LoadBMP(argv[1]);

src.x = 0;
src.y = 0;
src.h = 32;
src.w = 32

dst = src;

SDL_BlitSurface(bitmap, &src, tiles, &dst);

SDL_SaveBMP(tiles, file);


bill at newbreedsoftware.com Hire me!
http://newbreedsoftware.com/bill/ http://newbreedsoftware.com/bill/resume/

Use this very handy function which was posted on this list before:

void BlitTile(SDL_Surface *tiles, int tile_x, int tile_y,
int tile_width, int tile_height,
SDL_Surface *destination,
int dest_x, int dest_y)
{
SDL_Rect src, dest;

src.x = tile_x;
src.y = tile_y;
src.w = tile_width;
src.h = tile_height;

dest.x = dest_x;
dest.y = dest_y;
dest.w = tile_width;   /* Redundant */
dest.h = tile_height;  /* Redundant */

SDL_BlitSurface(tiles, &src, destination, &dest);

}

Nwo you just use the function to specify the X & y pos + size of the tile
you want to copy, and the x & y location of where you want to blit it.

Regards,
Tane Piper
http://tane.cream.org> ----- Original Message -----

From: salvodif@libero.it (Salvo Di Fazio)
To: “SDL”
Sent: 22 March 2003 18:28
Subject: [SDL] Tiles

Hi guys,
I have a little problem.
I would like to make a program to cut tiles from a bitmap.
So, I created two SDL_Surface, the first is bitmap and the second is
tiles.

Now I want to copy a part of bitmap into tiles… but I couldn’t do it

Following you will find my code… tnx

SDL_Surface *bitmap, *tiles;
SDL_Rect src, dst;

bitmap = SDL_LoadBMP(argv[1]);

src.x = 0;
src.y = 0;
src.h = 32;
src.w = 32

dst = src;

SDL_BlitSurface(bitmap, &src, tiles, &dst);

SDL_SaveBMP(tiles, file);


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

Yeah, but as I mentioned, his problem was his ‘destination’ surface was
never created. He just had some random pointer pointing off into
who-knows-where. ;^)

When I got to exactly duplicate a particular surface into a new surface
(like when I go to change the tint or color of a rubber stamp in Tux Paint),
I do this:

/* ‘amask’ is of type “Uint32” */

amask = ~(src->format->Rmask |
src->format->Gmask |
src->format->Bmask);

/* ‘newsurf’ is, of course, an “SDL_Surface *” /
/
And, obviously, so is the source surface, ‘src’! :^) */

newsurf = SDL_CreateRGBSurface(SDL_SWSURFACE,
src->w,
src->h,
src->format->BitsPerPixel,
src->format->Rmask,
src->format->Gmask,
src->format->Bmask,
amask);

And then, obviously, test ‘newsurf’ to see if it’s NULL.
If so, the ‘Create’ function failed for some reason.
(You can print the string returned by “SDL_GetError()” to stderr/stdout,
to show why, for example.)

-bill!On Sun, Mar 23, 2003 at 09:06:09PM -0000, Tane Piper wrote:

Use this very handy function which was posted on this list before:

bill at newbreedsoftware.com Hire me!
http://newbreedsoftware.com/bill/ http://newbreedsoftware.com/bill/resume/

oh, further to this I have actually uploaded some code you might find handy.
It is for a 2d engine I work on in my spare time. Not much to look at, the
code could be a lot more optimised, but I think its well commented, so you
should be able to use it eaily. you do need dev-c++ to compile, but if you
play around you can get into your complier of choice.

The link for it is http://tane.cream.org/filemgmt/visit.php?lid=5 and there
is a working exe for windows. Press e when it loads to see the editor
working.

Regards,

Tane Piper
http://tane.cream.org> ----- Original Message -----

From: @Tane_Piper (Tane Piper)
To:
Sent: 23 March 2003 21:06
Subject: Re: [SDL] Tiles

Use this very handy function which was posted on this list before:

void BlitTile(SDL_Surface *tiles, int tile_x, int tile_y,
int tile_width, int tile_height,
SDL_Surface *destination,
int dest_x, int dest_y)
{
SDL_Rect src, dest;

src.x = tile_x;
src.y = tile_y;
src.w = tile_width;
src.h = tile_height;

dest.x = dest_x;
dest.y = dest_y;
dest.w = tile_width;   /* Redundant */
dest.h = tile_height;  /* Redundant */

SDL_BlitSurface(tiles, &src, destination, &dest);

}

Nwo you just use the function to specify the X & y pos + size of the tile
you want to copy, and the x & y location of where you want to blit it.

Regards,
Tane Piper
http://tane.cream.org

----- Original Message -----
From: “Salvo Di Fazio”
To: “SDL”
Sent: 22 March 2003 18:28
Subject: [SDL] Tiles

Hi guys,
I have a little problem.
I would like to make a program to cut tiles from a bitmap.
So, I created two SDL_Surface, the first is bitmap and the second is
tiles.

Now I want to copy a part of bitmap into tiles… but I couldn’t do it

Following you will find my code… tnx

SDL_Surface *bitmap, *tiles;
SDL_Rect src, dst;

bitmap = SDL_LoadBMP(argv[1]);

src.x = 0;
src.y = 0;
src.h = 32;
src.w = 32

dst = src;

SDL_BlitSurface(bitmap, &src, tiles, &dst);

SDL_SaveBMP(tiles, file);


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

Hi,
Someone did create a program that divede amb bmp image in tiles with map
and palette, for windows or better for linux?
tnx

I think Mappy can do that.

http://www.tilemap.co.uk/mappy.php

/Jakob EklundOn Sun, 18 Jul 2004 01:54:50 +0200, NighTiger wrote:

Hi,
Someone did create a program that divede amb bmp image in tiles with map
and palette, for windows or better for linux?
tnx


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

Thank you very muchIl dom, 2004-07-18 alle 16:10, Jakob Eklund ha scritto:

I think Mappy can do that.

http://www.tilemap.co.uk/mappy.php

/Jakob Eklund

You can use “splitimage” too.

I loved it when I wanted to tile a full picture in 400 smallers ( auto
naming etc )

here
http://www.thecastle.com/software.html

I post it here, if anyone interested :slight_smile:
les.

NighTiger a ?crit :> Hi,

Someone did create a program that divede amb bmp image in tiles with map
and palette, for windows or better for linux?
tnx


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

You can also do that with Tile Studio. Then you can create a map of all
those 400 tiles and automatically remove the duplicates and export the
tiles and map to any format you want. It works under Linux too (with
Wine)

http://tilestudio.sf.net/

Mike

LesHauSsebons wrote:>

You can use “splitimage” too.

I loved it when I wanted to tile a full picture in 400 smallers ( auto
naming etc )

here
http://www.thecastle.com/software.html

I post it here, if anyone interested :slight_smile:
les.

NighTiger a ?crit :

Hi,
Someone did create a program that divede amb bmp image in tiles with map
and palette, for windows or better for linux?
tnx


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

Wiering Software - http://www.wieringsoftware.nl/