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

Author Topic: Image.LoadFromFile("sprite.tga") Won't load the im  (Read 30166 times)

0 Members and 1 Guest are viewing this topic.

maninboots

  • Newbie
  • *
  • Posts: 14
    • View Profile
Image.LoadFromFile("sprite.tga") Won't load the im
« Reply #15 on: August 21, 2007, 11:47:16 am »
Quote
maybe you can send your project files to someone that have visual c++ and see if it will works for him..my ide can import vc projects, however no vc compiler here on linux.. Confused


Ok, here's my project folder:
http://www.hakucenter.com/spriteTest.zip

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Image.LoadFromFile("sprite.tga") Won't load the im
« Reply #16 on: August 21, 2007, 11:59:21 am »
I opened / compiled / run you project without any error. The sprite is loaded and displayed correctly.
Laurent Gomila - SFML developer

maninboots

  • Newbie
  • *
  • Posts: 14
    • View Profile
Image.LoadFromFile("sprite.tga") Won't load the im
« Reply #17 on: August 21, 2007, 12:06:56 pm »
Ok, now thats really weird. Did you change anything, anything at all ?
If not, I'll try and reinstall Visual Studio and SFML.

Thanks for the help ! : :)

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Image.LoadFromFile("sprite.tga") Won't load the im
« Reply #18 on: August 21, 2007, 12:14:36 pm »
I just added the paths for SFML headers and libs, and linked with the debug versions of the libraries (but that shouldn't change anything).
Laurent Gomila - SFML developer

maninboots

  • Newbie
  • *
  • Posts: 14
    • View Profile
Image.LoadFromFile("sprite.tga") Won't load the im
« Reply #19 on: August 21, 2007, 05:59:57 pm »
How exactly did you do that ? I'm very new to C++ (been learning VB.Net in one year and I switched to C++ like 5 days ago).
Guess it's something basic that I've forgotten..

Mindiell

  • Hero Member
  • *****
  • Posts: 1261
    • ICQ Messenger - 41484135
    • View Profile
Image.LoadFromFile("sprite.tga") Won't load the im
« Reply #20 on: August 21, 2007, 06:04:05 pm »
Same problem here with code::blocks. My source is in a directory, and I got a bin/debug directory for my exe.

This path is working under EDI :
=> ./bin/debug/datas/image.gif : yes !

But it's no more working out of the EDI. So I think you just have to get a good "work path", like I'll try to do tonight with Code::Blocks  :wink:
Mindiell
----

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Image.LoadFromFile("sprite.tga") Won't load the im
« Reply #21 on: August 21, 2007, 07:09:41 pm »
Quote
Guess it's something basic that I've forgotten..

As your program compiles and runs, I think it's not related to the project setup. It's more a problem of working directory. Did you try to put your program and the image in the same directroy, and run it directly from there ?

You can also try to compile and run in release mode (to make sure the problem is not coming from the use of release libs in debug mode)..
Laurent Gomila - SFML developer

maninboots

  • Newbie
  • *
  • Posts: 14
    • View Profile
Image.LoadFromFile("sprite.tga") Won't load the im
« Reply #22 on: August 21, 2007, 07:33:18 pm »
Oh my god, I feel so stupid.. it worked in release mode ? How ?
Can I get it to work in debug mode also ?

Thanks for all the help !! :D

Edit: Well I can debug in release mode so I guess this is solved !! :D
THANKS! Very good support.. thumbs up for SFML and Laurent!

lubos

  • Newbie
  • *
  • Posts: 17
    • ICQ Messenger - 385328377
    • MSN Messenger - qwarmail@yahoo.co.uk
    • View Profile
Image.LoadFromFile("sprite.tga") Won't load the im
« Reply #23 on: August 21, 2007, 07:44:48 pm »
Quote from: "maninboots"

Edit: Well I can debug in release mode so I guess this is solved !! :D

debugging symbols shouldnt be produced in release mode, maybe it can break your program but it shouldnt be able to see some really detailed info..

maninboots

  • Newbie
  • *
  • Posts: 14
    • View Profile
Image.LoadFromFile("sprite.tga") Won't load the im
« Reply #24 on: August 21, 2007, 08:18:42 pm »
Quote from: "lubos"
Quote from: "maninboots"

Edit: Well I can debug in release mode so I guess this is solved !! :D

debugging symbols shouldnt be produced in release mode, maybe it can break your program but it shouldnt be able to see some really detailed info..


Ok, so how do I fix it so I can run it in Debug Mode ?

And another thing, can I load images with alpha channels ?
Photoshop doesn't support alpha channels in TGA so I tried to create an alpha with "TGA Tool", but I can't load that image in the program.

What's the use of sprites (in games) if you can't have an alpha channel ?
Is there a way to like - assign a special color to be the Alpha Channel Color (Like DirectX?),
so that I can output the image with like an Pink background and then let SFML make it transparent ?

Thanks

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Image.LoadFromFile("sprite.tga") Won't load the im
« Reply #25 on: August 21, 2007, 08:23:18 pm »
Quote
Ok, so how do I fix it so I can run it in Debug Mode ?

Just link with sfml-graphics-d.lib instead of sfml-graphics.lib (the same for other libraries -- sfml-window-d.lib and sfml-system-d.lib).

Quote
And another thing, can I load images with alpha channels ?

Yes, alpha channels are properly loaded ;)

Quote
Photoshop doesn't support alpha channels in TGA

Really ? If so, I guess you have an old version of Photoshop.

Quote
Is there a way to like - assign a special color to be the Alpha Channel Color (Like DirectX?),
so that I can output the image with like an Pink background and then let SFML make it transparent ?

As I said you can load the alpha channel directly, but if you want to make a particular color transparent after loading the image in your program, you can use the sfImage::CreateMaskFromColor function.
Laurent Gomila - SFML developer

maninboots

  • Newbie
  • *
  • Posts: 14
    • View Profile
Image.LoadFromFile("sprite.tga") Won't load the im
« Reply #26 on: August 21, 2007, 08:39:56 pm »
Quote
Just link with sfml-graphics-d.lib instead of sfml-graphics.lib (the same for other libraries -- sfml-window-d.lib and sfml-system-d.lib).


Ok Thanks ! :D

Quote
Photoshop doesn't support alpha channels in TGA


Sorry, I meant that Photoshop doesn't support automatic alpha channel (like for GIF and PNG), you have to make your own alpha channel in the channel window.

Quote
Yes, alpha channels are properly loaded Wink


Really ? I did make an alpha channel in photoshop and then saved it as an TGA, it didn't load. Then I tried with TGA Tool and made an alpha channel , didn't load either.

Quote
As I said you can load the alpha channel directly, but if you want to make a particular color transparent after loading the image in your program, you can use the sfImage::CreateMaskFromColor function.


Ok, I'll use that function if nothing else works!

Thanks

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Image.LoadFromFile("sprite.tga") Won't load the im
« Reply #27 on: August 21, 2007, 08:47:22 pm »
Quote
Really ? I did make an alpha channel in photoshop and then saved it as an TGA, it didn't load. Then I tried with TGA Tool and made an alpha channel , didn't load either.

What do you mean ? The loading caused an error ? Your sprite is showing but with no transparency ? Did you check some pixels to see if their alpha value are correct ?
Laurent Gomila - SFML developer

maninboots

  • Newbie
  • *
  • Posts: 14
    • View Profile
Image.LoadFromFile("sprite.tga") Won't load the im
« Reply #28 on: August 21, 2007, 09:46:52 pm »
It seems I got it to work, all of a sudden it takes .jpg .png everything, with or without alpha channels. I have no idéa of what I did, but it works!

Finally, I can start creating stuff.

Thanks! I'll be back sometime with more errors, I can feel it :) :D

Edit: But I do get 20 Warnings .. hmm

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Image.LoadFromFile("sprite.tga") Won't load the im
« Reply #29 on: August 22, 2007, 08:21:20 am »
Quote
Edit: But I do get 20 Warnings .. hmm

Which ones ? ;)
Laurent Gomila - SFML developer

 

anything