Gamestudio Links
Zorro Links
Newest Posts
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
0 registered members (), 1,103 guests, and 1 spider.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
Need a little programm (important for me) #277837
07/11/09 00:01
07/11/09 00:01
Joined: Mar 2008
Posts: 2,247
Baden Württemberg, Germany
Espér Offline OP
Expert
Espér  Offline OP
Expert

Joined: Mar 2008
Posts: 2,247
Baden Württemberg, Germany
Hi there..

I need a little program.

What it should do:
It should split a bitmap into 4 different bitmaps and save them with a number added to the name. ( same name as before.. but a number in the middle added ).

More Info:
like this Example:


See the new filenames. they include now numbers before "§".
These are the direction keys of the numblock. ( THEY ARE IMPORTANT! )

The images are all TGA. I need their Alpha to be saved too. So i can directly use the new bitmaps as sprites, without editing them anymore.

Why not Photoshop?:
i´ve nearly 200 Charsets like this to be edited.. really much for photoshop ^^


hoping for help.

Last edited by Espér; 07/11/09 00:03.

Selling my Acknex Engine Editions (A7 Com & A8 Pro):
>> click here if you are interested <<
Re: Need a little programm (important for me) [Re: Espér] #277860
07/11/09 05:17
07/11/09 05:17
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline
Expert
EvilSOB  Offline
Expert

Joined: Feb 2008
Posts: 3,232
Australia
Im sure you could probably get this code to do the job you want

But I would suggest looking at my suggestion in your other sprite thread first.
Code:
#ifndef bmap_slice_c
#define bmap_slice_c
/////////////////////////////////////////////////////////////////////////////////////////
//
//		BMAP_SLICE.C
//			Function to take a 3DGS compatible image file(SourceName) and slice it into an
//			array of BMP's of chosen size(Out_Width by Out_Height), and save them
//			to a chosen folder(TargetName[path \\ delimited]), with a chosen filename
//			prefix(end of TargetName) with a numeric representation of its array index.
//			[NOTE] Out_Width/Height MUST be a 'power of eight' number. (8,16,32,etc)
//			Returns 'true' if sucsessful, 'false' if an error occured.
//		Created :    05-01-2009
//		Includes:   None
//
/////////////////////////////////////////////////////////////////////////////////////////
////
////
function bmap_slice(STRING* SourceName, STRING* TargetName, var Out_Width, var Out_Height)
{
   BMAP* SourceBMP = NULL;		SourceBMP = bmap_create(SourceName);
   if(SourceBMP==NULL)	return(0);										//Source File Not Found
   //
   var T_Width  = integer(SourceBMP.width  / Out_Width ) + 1;   
   var Width_Name_Length  = str_len(str_for_int(NULL, T_Width ));  
   if(T_Width<8)	{	ptr_remove(SourceBMP);	return(0);	}		//Target Width below min
   //
   var T_Height = integer(SourceBMP.height / Out_Height)+1;   
   var Height_Name_Length = str_len(str_for_int(NULL, T_Height));
   if(T_Height<8)	{	ptr_remove(SourceBMP);	return(0);	}		//Target Height below min
   BMAP*	TargetBMP = NULL;		VECTOR tmpV0, tmpV1;
   STRING*	BuildName = "";	STRING* SaveName = "";
   //
   int xx,yy;   for(yy=0; yy<T_Height; yy++)   for(xx=0; xx<T_Width; xx++)
   {
      str_cpy(SaveName, TargetName);
      str_cpy(BuildName, "");   
         str_cat_num(BuildName, "0000000000%.0f", xx);
         str_clip(BuildName, (str_len(BuildName) - Width_Name_Length));
      str_cat(SaveName, BuildName);      str_cat(SaveName, "_");
      str_cpy(BuildName, "");   
         str_cat_num(BuildName, "0000000000%.0f", yy);
         str_clip(BuildName, (str_len(BuildName) - Height_Name_Length));
      str_cat(SaveName, BuildName);      str_cat(SaveName, ".bmp");
      if(TargetBMP!=NULL)   bmap_remove(TargetBMP);
      TargetBMP = bmap_createblack(Out_Width,Out_Height,(SourceBMP.bytespp*8));
      vec_set(tmpV0, vector(xx*Out_Width,yy*Out_Height,0));
      vec_set(tmpV1, vector(Out_Width,Out_Height,0));
      bmap_blitpart(TargetBMP, SourceBMP, NULL, NULL, tmpV0, tmpV1);   
      bmap_save(TargetBMP, SaveName);
   }
   ptr_remove(SourceBMP);   ptr_remove(TargetBMP);   
   ptr_remove(BuildName);   ptr_remove(SaveName);
   return(1);   //sucessful.
}
//
#endif   //bmap_slice_c




"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Re: Need a little programm (important for me) [Re: EvilSOB] #278060
07/11/09 23:18
07/11/09 23:18
Joined: Mar 2008
Posts: 2,247
Baden Württemberg, Germany
Espér Offline OP
Expert
Espér  Offline OP
Expert

Joined: Mar 2008
Posts: 2,247
Baden Württemberg, Germany
hmm.. how is this working???

i created it as a new script.. included it to main..
and called it this way:
Code:
while(key_p == 0){wait(1);}
	var slicemap;
	BMAP* slicebit = bmap_create("Graphics/Characters/GegnerWeisserDrachenreiterstehen_%4.png");
	slicemap = bmap_lock(slicebit,0);
	bmap_slice("Graphics/Characters/GegnerWeisserDrachenreiterstehen_%4.png", 
	"Graphics/Characters/GegnerWeisserDrachenreiterstehen_%4.tga", 
	slicebit.width, 
	slicebit.height/4);
	bmap_unlock(slicebit);
	ptr_remove(slicebit);
	beep();



But it seems that nothing happens..
I tired with path.. without path. TGA => TGA, PNG => PNG, PNG => TGA, TGA => PNG..
nothing... But no error.. and the beep is played..


Selling my Acknex Engine Editions (A7 Com & A8 Pro):
>> click here if you are interested <<
Re: Need a little programm (important for me) [Re: Espér] #278207
07/12/09 16:38
07/12/09 16:38
Joined: Apr 2002
Posts: 117
Spain
Abstracto Offline
Member
Abstracto  Offline
Member

Joined: Apr 2002
Posts: 117
Spain
i think there is a problem with the "%4"
on the bitmap's file name,

Re: Need a little programm (important for me) [Re: Abstracto] #278210
07/12/09 16:51
07/12/09 16:51
Joined: Mar 2008
Posts: 2,247
Baden Württemberg, Germany
Espér Offline OP
Expert
Espér  Offline OP
Expert

Joined: Mar 2008
Posts: 2,247
Baden Württemberg, Germany
hmm.. i don´t think so.. because without it.. there nothing happens too ^^


Selling my Acknex Engine Editions (A7 Com & A8 Pro):
>> click here if you are interested <<
Re: Need a little programm (important for me) [Re: Espér] #278230
07/12/09 18:28
07/12/09 18:28
Joined: Oct 2004
Posts: 4,134
Netherlands
Joozey Offline
Expert
Joozey  Offline
Expert

Joined: Oct 2004
Posts: 4,134
Netherlands
If you knew how to use photoshop you could fix this within minutes. Auto action for the win!
Not that I support this way, you'd better create a script that cuts the bitmaps on the fly at startup smile.


Click and join the 3dgs irc community!
Room: #3dgs
Re: Need a little programm (important for me) [Re: Joozey] #278233
07/12/09 18:43
07/12/09 18:43
Joined: Mar 2008
Posts: 2,247
Baden Württemberg, Germany
Espér Offline OP
Expert
Espér  Offline OP
Expert

Joined: Mar 2008
Posts: 2,247
Baden Württemberg, Germany
the problem with photoshop...

i know how to record an action..

But how to say photoshop to cut any size of images ( they are not all in the same size ) into their quarter of high.. and save it with that special number in the name??

Last edited by Espér; 07/12/09 18:44.

Selling my Acknex Engine Editions (A7 Com & A8 Pro):
>> click here if you are interested <<
Re: Need a little programm (important for me) [Re: Espér] #278236
07/12/09 19:02
07/12/09 19:02
Joined: Oct 2004
Posts: 4,134
Netherlands
Joozey Offline
Expert
Joozey  Offline
Expert

Joined: Oct 2004
Posts: 4,134
Netherlands
If they are not the same size, you'll be having a hard time with programming anyway.
You can add a "special number" in the name I think, but doing this can't be good programming.


Click and join the 3dgs irc community!
Room: #3dgs
Re: Need a little programm (important for me) [Re: Joozey] #278239
07/12/09 19:16
07/12/09 19:16
Joined: Mar 2008
Posts: 2,247
Baden Württemberg, Germany
Espér Offline OP
Expert
Espér  Offline OP
Expert

Joined: Mar 2008
Posts: 2,247
Baden Württemberg, Germany
photoshop can´t ask for "bitmap.height / 4".. a programming language is able to do that..

That´s why i ask for a programm.. not a tipp for photoshop ^^


Selling my Acknex Engine Editions (A7 Com & A8 Pro):
>> click here if you are interested <<
Re: Need a little programm (important for me) [Re: Espér] #278247
07/12/09 19:50
07/12/09 19:50
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline
Expert
EvilSOB  Offline
Expert

Joined: Feb 2008
Posts: 3,232
Australia
Sorry for the delay, I dont come down the this forum often enough i think.

Abstracto was right at the start "%" is a special character to 3dGS.
Anytime you want it in a string, you need to put %% instead,
kindof like \ needs to be \\ sometimes.

Otherwise your code looks OK.


"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Page 1 of 2 1 2

Moderated by  adoado, checkbutton, mk_1, Perro 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1