2 registered members (Akow, tomaslolo),
1,536
guests, and 12
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
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
OP
Expert
|
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.
|
|
|
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
Expert
|
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.
#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
OP
Expert
|
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:
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..
|
|
|
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
Expert
|
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 .
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
OP
Expert
|
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.
|
|
|
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
Expert
|
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
|
|
|
|