Results 1 to 4 of 4

Thread: How to convert clan::Image to grayscale?(clanlib3.0)

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1

    Default How to convert clan::Image to grayscale?(clanlib3.0)

    How to convert clan::Image to grayscale?(clanlib3.0)

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

    Default

    I can't remember ClanLib 3.0 API, but for ClanLib 4.0 you can't do that automatically.

    However there can be workarounds
    1. Create a GLSL shader to convert the image to greyscale. This is quite tricky, for various reasons. If interested, the HSVSprite does something similar

    2. Manually convert the image (in ClanLib 4.0 speak)
    Code:
    	clan::PixelBuffer pixels(filename);
    	(pixels should be in rgba8 format)
    	clan::Size size = pixels.get_size();
    	for (int ycnt=0; ycny < size.height; ycnt++)
    	{
    		unsigned int *ptr = pixels.get_line_uint32(ycnt);
    		for (int xcnt = 0; xcnt < size.width; xcnt++, ptr++)
    		{
    			unsigned char *cptr = (unsigned char *)(ptr);
    			// NOTE -- I cannot remember the RGBA order in ClanLib 3.0, so these maybe cptr[1], cptr[2] and cptr[3]
    			int colour = ( cptr[0] + cptr[1] + cptr[2] ) / 6;
    			cptr[0] = colour;
    			cptr[1] = colour;
    			cptr[2] = colour;
    
    		}
    	}
    	clan::Image image(canvas, pixels, size);
    Btw, nobody uses these forums any more.

  3. #3

    Default

    any new forum?
    Last edited by kyelin; 01-14-2016 at 07:07 AM.

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

    Default

    No.

    Some developers hang out occasionaly on IRC #clanlib @ freenode.net

    All developers don't have any free time. We decided that it's better to concentrate on programming. Thus we dropped the website and ClanLib is now a github project.

    It seems to work out better. Developers tune ClanLib to fit their individual needs, thus create their own fork.

    The official ClanLib github project https://github.com/sphair/ClanLib API is the best we can get it. There will not be any more major changes in the foresable future.

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
  •