Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - Balder

Pages: [1]
1
Graphics / Problem with colours [SOLVED]
« on: November 23, 2009, 05:25:35 am »
After loading the image with the valuable help of Laurent (you'll get in the acknoledgements right now haha) I've noticed that the colours are not correct. But I think it's sfml responsability as when I output the file in TGA I see it correctly. This is an screenshot of the problem:



And here the code responsible for showing that:

Code: [Select]
void ICN::showFrame( RenderWindow *Window, unsigned short nFrame, unsigned short x, unsigned short y )
{
Image Frame; // Create image instance
ostringstream outputBuffer; // Output buffer to store decoded pixels

decodePixels( outputBuffer, nFrame ); // Fill buffer with the decoded pixels of the indicated frame of ICN group of images

if( !Frame.LoadFromPixels( getFrameWidth(nFrame), getFrameHeight(nFrame), (Uint8 *)outputBuffer.str().data() ) ) // Cargamos la imagen desde el búfer de pixeles
{
fprintf( stderr, "Couldn't load pixels!" );
exit( EXIT_FAILURE );
}

Sprite Sprite( Frame ); // Create drawable sprite from image
Sprite.SetPosition( x, y ); // Place sprite in position

Window->Draw( Sprite ); // Draw sprite in window
}


BUT, when I do this:

Code: [Select]
Uint8 *pointer = (Uint8 *)outputBuffer.str().data();
fwrite( pointer, outputBuffer.str().length(), 1, outputFile );


I get a perfect TGA image.

Any ideas? :roll:

2
Graphics / Doubt using Image::LoadFromMemory
« on: November 20, 2009, 05:50:54 am »
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:

Code: [Select]
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.

3
General / Strange error linking statically
« on: October 22, 2009, 03:00:09 am »
I followed the tutorial and I got to compile the basic window program with Visual Studio Express 2008 (dynamically).

When I change the Additional Dependencys from sfml-main.lib sfml-window.lib sfml-system.lib to sfml-main.lib sfml-windows-s.lib sfml-system-s.lib I get the following compilation errors:

Error   1   error LNK2001: símbolo externo __imp___invalid_parameter_noinfo sin resolver   sfml-window-s.lib
Error   2   error LNK2019: símbolo externo __imp___invalid_parameter_noinfo sin resolver al que se hace referencia en la función "public: bool __thiscall sf::Window::GetEvent(class sf::Event &)" (?GetEvent@Window@sf@@QAE_NAAVEvent@2@@Z)   sfml-window-s.lib
Error   3   error LNK2001: símbolo externo __imp___invalid_parameter_noinfo sin resolver   sfml-window-s.lib
Error   4   error LNK2001: símbolo externo __imp___invalid_parameter_noinfo sin resolver   sfml-window-s.lib
Error   5   error LNK2001: símbolo externo __imp___invalid_parameter_noinfo sin resolver   sfml-window-s.lib
Error   6   fatal error LNK1120: 1 externos sin resolver   C:\Documents and Settings\José Antonio\Mis documentos\Visual Studio 2008\Projects\sfmlWindow\Debug\sfmlWindow.exe   1

I tried many things but still no idea why static compilation is failing!

Can anyone help?  :roll:  Just came from SDL and have no idea!

Pages: [1]
anything