Results 1 to 8 of 8

Thread: Not a valid XML resource file exception

  1. #1
    Knight
    Join Date
    Feb 2009
    Location
    I looked through my window, there are no signs ... but, its definitely planet Earth.
    Posts
    88

    Default Not a valid XML resource file exception

    According to documenation only name attribute and at least one image is needed to construct CL_Sprite and for a resource XML file to be valid. Here's my resource file, I'm trying to use glyphs for a font:

    <sprite name="font">

    <!-- Frame image loading: -->

    <image file="./gfx/a.png" />
    <image file="./gfx/b.png" />
    <image file="./gfx/c.png" />
    <image file="./gfx/d.png" />
    <image file="./gfx/e.png" />

    </sprite>


    Here's a constructor:

    CFont::CFont()
    {
    resource = CL_ResourceManager("./sprites/font.xml");

    glyphs = CL_Sprite( "font", &resource );
    //letters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
    letters = "ABCDE";

    font = CL_Font( glyphs, letters );
    }

  2. #2
    ClanLib Developer
    Join Date
    Sep 2006
    Location
    Bergen, Norway
    Posts
    588

    Default

    Did you include the ?xml and resource tags?


    <?xml version="1.0" encoding="iso-8859-1"?>
    <resources>
    <sprite....>
    </sprite>
    </resources>

  3. #3
    Knight
    Join Date
    Feb 2009
    Location
    I looked through my window, there are no signs ... but, its definitely planet Earth.
    Posts
    88

    Default

    No, I haven't because it was not like that in the documentation .. am I stupid or what THANKS!

  4. #4
    Knight
    Join Date
    Feb 2009
    Location
    I looked through my window, there are no signs ... but, its definitely planet Earth.
    Posts
    88

    Default

    I have a transparent png image for each of listed letters, but they appear with white background on screen. Is there a way to set transparency? Also, is there a way to set key color transparency, like magenta or any other color. In these png font files, there is no background color at all, I assumed that it would be transparent on screen as well. Can you help? Sorry for bothering you this much.

  5. #5
    ClanLib Developer
    Join Date
    Sep 2006
    Location
    Bergen, Norway
    Posts
    588

    Default

    If the pngs are true 32bit images with an alpha channel, they should be transparent automatically when loaded. Not sure why you get a white background. Try with some of the pngs from Examples\SpritesRTS\Gfx and see if those works. if so, you need to make sure your pngs are saved correctly with a proper alpha channel.

    I'm pretty sure ClanLib supports colorkeying, but I cannot remember how. Not sure CL_Sprites handle it automatically. Maybe you need to load them manually using CL_PixelBuffer or similar. I know that Novashell (www.rtsoft.com) uses this feature, so it is there somewhere...

  6. #6
    Administrator Seth's Avatar
    Join Date
    Jul 2002
    Location
    Japan
    Posts
    5,345

    Default

    Right, color key should be settable like this: (look for the transparent_color tag in the xml below)
    Code:
    <sprite name="idle_left">
    	<image fileseq="idle/DS-I4-.BMP" leading_zeroes="1" transparent_color="255,255,255"/>
    	<translation origin="top_left"/>
    	<animation pingpong="no" loop="yes" speed="250"/>
    </sprite>
    Seth A. Robinson
    Robinson Technologies

  7. #7
    Knight
    Join Date
    Feb 2009
    Location
    I looked through my window, there are no signs ... but, its definitely planet Earth.
    Posts
    88

    Default

    You were right it was PNG-8 (but with transparency set, now when PNG-24 is used its working! Thanks a lot!

  8. #8
    Knight
    Join Date
    Feb 2009
    Location
    I looked through my window, there are no signs ... but, its definitely planet Earth.
    Posts
    88

    Thumbs up

    Thank you both! Its working either by using transparent_color or saving as 32-bit PNG (I only have PNG-24 format available). There are few dots that remain colored with either white in case of 32bit png or magenta in case of transparent_color. Transparent_color tag is not described in docs at all. Thanks again.

Similar Threads

  1. some patches - std::exception, cl_vector, ostream, etc
    By logixoul in forum Official ClanLib SDK Forums
    Replies: 1
    Last Post: 07-07-2008, 04:05 PM
  2. Have CL_Error inherit from std::exception
    By SnT2k in forum Official ClanLib SDK Forums
    Replies: 2
    Last Post: 06-24-2008, 06:57 AM
  3. Problems with resource file
    By LonelyStar in forum Official ClanLib SDK Forums
    Replies: 0
    Last Post: 04-26-2008, 12:25 PM
  4. Exception every time I try to move stuff
    By cpury in forum Novashell Game Creation System
    Replies: 9
    Last Post: 03-01-2007, 11:26 AM
  5. resource.dat
    By redink1 in forum Other RTsoft Games
    Replies: 1
    Last Post: 11-15-2002, 10:08 PM

Bookmarks

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •