I have a brick.sprite. I have a executable in Debain 8 "Kali Linux" with this code:
#include <stdio.h>
#include <stdint.h>
#include <iostream>
/**
* To use this file, pipe a sprite of the old format into stdin, and
* redirect stdout to a second file of your chosing. The sprite header
* will be converted. This tool has no error checking and assumes a valid
* sprite header. It is provided merely for convenience.
*/
int main( int argc, char *argv[] )
{
uint8_t zero = 0;
uint8_t val;
int ret;
/* Read in old width */
ret = fread( &val, sizeof( val ), 1, stdin );
/* Write empty value and then new */
fwrite( &zero, sizeof( zero ), 1, stdout );
fwrite( &val, sizeof( val ), 1, stdout );
/* Read in old height */
ret = fread( &val, sizeof( val ), 1, stdin );
/* Write empty value and then new */
fwrite( &zero, sizeof( zero ), 1, stdout );
fwrite( &val, sizeof( val ), 1, stdout );
/* Straight copy of bitdepth and format */
ret = fread( &val, sizeof( val ), 1, stdin );
fwrite( &val, sizeof( val ), 1, stdout );
ret = fread( &val, sizeof( val ), 1, stdin );
fwrite( &val, sizeof( val ), 1, stdout );
/* Assuming horizontal and vertical stride of 1 */
val = 1;
fwrite( &val, sizeof( val ), 1, stdout );
fwrite( &val, sizeof( val ), 1, stdout );
printf("%d\n",ret);//set to avoid weird error
/* Now just byte copy until end of stream */
while( !feof( stdin ) )
{
ret = fread( &val, sizeof( val ), 1, stdin );
if( !feof( stdin ) )
{
/* Only copy out if the last read didn't make an eof */
fwrite( &val, sizeof( val ), 1, stdout );
}
}
return 0;
}
to convert the brick.sprite to a new format. I tried it with many codes:
//convtool is the executable
convtool grep <brick.sprite date > brick2.sprite
convtool <brick.sprite> brick2.sprite //This looks like that it goes in the right way...
convtool cat <brick.sprite> brick2.sprite
convtool 2> brick2.sprite > brick.sprite
I'm not familiar with linux but I need to know that.
Thanks for advices!
If you intent to redirect the content of you file "brick.sprite" to the stdin of the "convtool" you use the
<
operator.An alternative would be to cat (write the content of a file to stdout) the content and pipe it into your tool.
It seams that you also want to redirect the output of you tool to a new file brick2.sprite. Redirecting the output to a file is done by the
>
operator.To complete both variants from above:
The first variant schould also work on windows and osx shells it is not linux specific.
Some hints: