Results 1 to 5 of 5

Thread: CL_PixelBuffer Problem.

  1. #1
    Lesser Knight
    Join Date
    Sep 2010
    Location
    Germany
    Posts
    36

    Default CL_PixelBuffer Problem.

    Hello,

    I wanted to use GIMP as level editor for my game. A green dot (0, 255, 0) will be the spawn point for the player but:
    When I load the .PNG file in the CL_PixelBuffer class I get the following error:

    Code:
    Error: contour has less than 2 points.
    I'm not sure what that means...

    Here's the part of the code:
    Code:
    CL_PixelBuffer buffer = CL_PNGProvider::load( "level\\standard\\level01.png" ); <-- Error here
    for( int x = 0; x <= 799; x++ )
    {
        for( int y = 0; y <= 599; y++ )
        {
             if( buffer.get_pixel( x, y ) == CL_Colorf::lime )
    	 {
    	     // Init stuff
    	 }
         }
    }
    I've attached the "level01.png" to the post if that helps.


    Thanks!
    Tuisto
    Attached Images Attached Images  

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

    Default

    I can't see how that is possible - the error you get is from the collision code in ClanLib... are you sure that is the faulting line?

  3. #3
    Lesser Knight
    Join Date
    Sep 2010
    Location
    Germany
    Posts
    36

    Default

    Well, the breakpoints tricked me...
    Sorry for that.

    It must be this line above the PixBuff then. Just checked it again.

    Code:
    m_pImgCol = new CL_CollisionOutline( "level\\standard\\level01.png" );

  4. #4
    ClanLib Developer
    Join Date
    May 2007
    Posts
    1,824

    Default

    Try...

    CL_PixelBuffer original( "level\\standard\\level01.png" );
    CL_PixelBuffer rgba = original.to_format(cl_rgba8);
    m_pImgCol = new CL_CollisionOutline(rgba);

    If not, try cl_rgb8 instead of cl_rgba8 in the above code

    Else, have a look at: Tests/Display/Collision <--- It's a very good example

    Have a look at: Tests/Display/Collision/Images as well

  5. #5
    Lesser Knight
    Join Date
    Sep 2010
    Location
    Germany
    Posts
    36

    Default

    I didn't change a thing of the code but now it works...
    im confused but thanks for your help anyways!

    great and fast help on this forum!

Similar Threads

  1. operate CL_PixelBuffer as CL_Surface
    By DavinciZhe in forum Official ClanLib SDK Forums
    Replies: 1
    Last Post: 11-12-2009, 06:05 PM
  2. CL_PixelBuffer::get_pixel() weird results...
    By Otto (Strange) Halmén in forum Official ClanLib SDK Forums
    Replies: 4
    Last Post: 12-06-2006, 07:36 AM

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
  •