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

Author Topic: Problem with colours [SOLVED]  (Read 7456 times)

0 Members and 1 Guest are viewing this topic.

Acetate

  • Newbie
  • *
  • Posts: 8
    • View Profile
Problem with colours [SOLVED]
« Reply #15 on: November 24, 2009, 09:05:28 pm »
From what I recall the typical color layout for Targa is BGRA, may it have something to do with the issue?

Balder

  • Newbie
  • *
  • Posts: 26
    • View Profile
Problem with colours [SOLVED]
« Reply #16 on: November 24, 2009, 09:42:00 pm »
Humm... I'm outputing the targa as what I think RGBA format, but maybe I have mismatched the palette's colour, so I'll test changing it so try all combinations and see if the screen image gets correct.

Anyway there are many TGA-based formats depending on the 18 byte header. I was almost sure that the one I use is RGBA but I'd like to try that.
Thanks for the advice!

Balder

  • Newbie
  • *
  • Posts: 26
    • View Profile
Problem with colours [SOLVED]
« Reply #17 on: November 24, 2009, 10:04:34 pm »
Solved man!! Now what's wrong is the output file LOL

What I still don't know is why LoadFromPixels uses BGRA format as documentation doesn't state that but RGBA. Does this mean that I have to do two decode functions, one for LoadFromPixels(BGRA) and other one for outputting the file? (RGBA)

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Problem with colours [SOLVED]
« Reply #18 on: November 24, 2009, 11:08:00 pm »
LoadFromPixels takes RGBA.
Laurent Gomila - SFML developer

Balder

  • Newbie
  • *
  • Posts: 26
    • View Profile
Problem with colours [SOLVED]
« Reply #19 on: November 24, 2009, 11:16:38 pm »
Yeah that's what I read but still there's a difference in the ouptut produced by loadFromPixels() and the same content when I write to a file. (If I pass it like BGRA loadFromPixels() work and if I pass it like RGBA the output file is okay) As I'm not doing any operation to change those things and just passing the colour vector both to the file writer and loadFromPixels I don't understand this difference. :(

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Problem with colours [SOLVED]
« Reply #20 on: November 24, 2009, 11:28:35 pm »
Unless you know exactly what byte ordering / endianess the TGA format uses for storing pixels, you can't expect the same results as SFML's images with the same input.

Have you read the TGA format specs first? ;)

PS: I didn't have time to look at your code today, I'll try to do it tomorrow.
Laurent Gomila - SFML developer

Balder

  • Newbie
  • *
  • Posts: 26
    • View Profile
Problem with colours [SOLVED]
« Reply #21 on: November 25, 2009, 12:12:31 am »
Image Data Field:

This field specifies (width) x (height) color map indices.  Each index is stored as an integral number of bytes (typically 1 or 2).   All fields are unsigned.
The low-order byte of a two-byte field is stored first.

That might be actual problem. So I think I have to make two versions of the decode function decodeRGBA and decode BGRA. :?

And then the before output file was working by fortitude, as I called red blue and blue red LOL

Don't hurry Laurent I think the problem is already clarified. Lots of thanks for the help, I think I was too obfuscated to find the solution myself. :wink:

 

anything