Good (and late) night! (sigh)
I'm using sfml to remake an old game. A feature that I liked from sfml is the ability to load images from pixels in memory.
The thing is that I have coded a tool that can convert the old game images (paletized, 8-bit, with some compression codes) to a raw tga file.
The problem is that I can't figure how to do that in memory! As I can't use write statements to output things to RAM don't know how to "convert" this algorithm of many cases and a bit of complexity so that it operates without the need of creating a temporary output file.
I know that I just could create that temporary file and use LoadFromFile but it would be much neater if I could do that operations on memmory.
A small portion of the algorithm, as an example:
fread( &n, sizeof(n), 1, fichero );
switch( n )
{
case 0: // End of line, fill the rest of widht as translucid
if( (pixelesEscritos % encabezadoTGA.width) != 0 )
{
pixelesRestantes = encabezadoTGA.width - pixelesEscritos % encabezadoTGA.width;
for( int i = 0; i < pixelesRestantes; i++ )
fwrite( &transparente, sizeof(transparente), 1, output );
pixelesEscritos += pixelesRestantes;
}
break;
case 128: // End of image, fill as translucid the widht*height
if( pixelesEscritos < encabezadoTGA.width * encabezadoTGA.height )
{
for( int i = 0; i < (pixelesEscritos - (encabezadoTGA.width * encabezadoTGA.height)); i++ )
{
fwrite( &transparente, sizeof(transparente), 1, output );
pixelesEscritos++;
}
}
seguir = false;
break;
There are other two special cases(n=192, n=193) and three default cases (n>0, n>128, n>193).
The thing is how to make all that without the needing of an output file, if possible. I know this is more a technique/pro. language related question than sfml topic, but I think exploiting this sfml feature will come very handy.