Results 1 to 3 of 3

Thread: CL_PixelBuffer question again...

Threaded View

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

    Default CL_PixelBuffer question again...

    With the great help of magnus norddahl I got this nice function to read pixels out of a pixbuf:

    Code:
    	CL_PixelBuffer buffer( "image.png" );
    	CL_PixelBuffer rgba = buffer.to_format(cl_rgba8);
    	rgba.lock( cl_access_read_only );
    	unsigned int *data = reinterpret_cast<unsigned int*>(rgba.get_data());
    	unsigned int width = rgba.get_width();
    	unsigned int height = rgba.get_height();
    
    	for( unsigned int y = 0; y < height; y++ )
    	{
    		unsigned int *line = data+y*width;
    		for( unsigned int x = 0; x < width; x++ )
    		{
    			unsigned int pixel = line[x];
    			unsigned int red = (pixel >> 24) & 0xff;
    			unsigned int green = (pixel >> 16) & 0xff;
    			unsigned int blue = (pixel >> 8) & 0xff;
    
                             // write to pixbuf if color == xyz
    
    		}
    	}
    
    	rgba.unlock();
    How can I write to the PixBuf?
    I can't make head nor tail of the documentation...

    Thanks
    Last edited by Tuisto; 01-21-2011 at 05:27 PM.

Similar Threads

  1. CL_PixelBuffer Problem.
    By Tuisto in forum Official ClanLib SDK Forums
    Replies: 4
    Last Post: 01-20-2011, 06:42 PM
  2. CL_PixelBuffer::get_pixel()
    By Tuisto in forum Official ClanLib SDK Forums
    Replies: 2
    Last Post: 01-20-2011, 04:51 PM
  3. operate CL_PixelBuffer as CL_Surface
    By DavinciZhe in forum Official ClanLib SDK Forums
    Replies: 1
    Last Post: 11-12-2009, 06:05 PM
  4. 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
  •