Page 1 of 1

I want to make circle Image

Posted: Fri Dec 16, 2011 20:20
by dragonblood
Hi,

I want to make circle Image, dynamically, in my program. I made an image with render to texture in Ogre and in CEGUI I want to transform this image to be a circle. I think I have to add alpha on my image but i don't know how to do this in my program. an idea ?





Sorry for my english

A+

Re: I want to make circle Image

Posted: Wed Dec 21, 2011 17:41
by Jamarr
This topic has been asked several times in the past. Have you tried searching the forum or searching the wiki? You might try searching for terms like: circle, round, alpha, etc.

Make sure you fulfill the Forum Usage Guidelines as community members will be more inclined to help you, if you show that you have followed them. Thanks!

Re: I want to make circle Image

Posted: Sun Dec 25, 2011 17:57
by dragonblood
Ok i've search and I've not found any topic that answer my question

I found these topic and some others about circle image :

viewtopic.php?f=10&t=2151
viewtopic.php?f=10&t=5397
viewtopic.php?f=2&t=4903

But all of these, it tell to use .png or targa image or to use property alpha.

But that I want is to make alpha at some location in my image to render it like a circle and I can't use a .png because my image is create in my program


Sorry for my english

Re: I want to make circle Image

Posted: Tue Dec 27, 2011 17:35
by Jamarr
dragonblood wrote:But that I want is to make alpha at some location in my image to render it like a circle and I can't use a .png because my image is create in my program


Well it does not really matter how the image is made, so long as the image uses alpha. A .png is just an image format that supports alpha. Your best option is to still use alpha-transparency to manually clip (shape) your imagery. If you create the image dynamically within the program, then you also need to dynamically apply transparency to the image. How you go about doing that is not really a concern of CEGUI. This is because CEGUI is not designed to be an image-manipulation library, rather it combines user-specified imagery and user-specified input to form an interactive GUI.

That said, I suppose one approach would be some form of masking. You would apply the mask by dynamically adding alpha-transparent pixels to the image either during creation or in post-processing. If you are already creating the image dynamically at run-time, it should be a fairly trivial step from there to add alpha-transparency to it.

Note that once you start using non-rectangular geometry you may want to clip your input regions as well. CE has already written an article on hit testing on the wiki.

Re: I want to make circle Image

Posted: Tue Dec 27, 2011 20:43
by dragonblood
Hi,

Your best option is to still use alpha-transparency to manually clip (shape) your imagery

"by dynamically adding alpha-transparent pixels to the image either during creation or in post-processing.

it should be a fairly trivial step from there to add alpha-transparency to it."


Ok this is the subject of my topic... But how can I do that ? there is any example ?

Re: I want to make circle Image

Posted: Tue Dec 27, 2011 21:05
by Kulik
I don't understand what's your problem really.

Do you know the concept of alpha transparency?

Re: I want to make circle Image

Posted: Tue Dec 27, 2011 21:13
by dragonblood
Yes I know the concept of alpha transparency but I don't know how to add transparency to a CEGUI::Image. If you know you could tell me ?

Re: I want to make circle Image

Posted: Tue Dec 27, 2011 21:48
by Kulik
Make a buffer, put the colours there, load that into CEGUI::Image, boom!

I am really confused what the problem is. Are you expecting me to write the code for you?

Re: I want to make circle Image

Posted: Wed Dec 28, 2011 18:47
by dragonblood
I try this code just to test but nothing happen

Code: Select all

// I send my Ogre::Texture to CEGUI::Texture
CEGUI::Texture &ceguiTexture = CEGUI::OgreRenderer::create().createTexture(pTexture);
   
// I create Imageset and image
CEGUI::Imageset &imageSet = CEGUI::ImagesetManager::getSingleton().create(mName+"/CibleImageset", ceguiTexture);   
CEGUI::Image mImage=imageSet.getImage(mName+"/CibleImage");


// I create a buffer
CEGUI::GeometryBuffer &mBuffer= CEGUI::OgreRenderer::create().createGeometryBuffer();
mBuffer.setActiveTexture(&ceguiTexture);

CEGUI::Vector2 *mVector=new CEGUI::Vector2(0.1,0.1);
CEGUI::Size *mSize=new CEGUI::Size(ceguiTexture.getSize());
CEGUI::Rect *mRect=new CEGUI::Rect(0.5,0.1,5.0,1.0);
CEGUI::Rect *mRect2=new CEGUI::Rect(1.0,1.1,12.0,9.0);
CEGUI::Rect *mRect3=new CEGUI::Rect(1.0,1.1,12.0,9.0);
CEGUI::ColourRect *mColorRect=new CEGUI::ColourRect(CEGUI::colour(0xFFAABB00));
mColorRect->setAlpha(0.5);

// I try to change the texture
for (int i=0;i<=ceguiTexture.getSize().d_height;i++){
      for (int j=0;j<=ceguiTexture.getSize().d_width;j++){
            mVector->d_x++;
            mVector->d_y++;

            mRect->d_bottom++;
            mRect->d_left++;
            mRect->d_right++;
            mRect->d_top++;

            mRect2->d_bottom++;
            mRect2->d_left++;
            mRect2->d_right++;
            mRect2->d_top++;

            mSize->d_height++;
            mSize->d_width++;

            mImage.draw(mBuffer, *mRect, *mRect2, mRect3,*mColorRect );
           
       }
    }

   // I create another imageset with the texture in the buffer
    CEGUI::Imageset &imageSet2 = CEGUI::ImagesetManager::getSingleton().create(mName+"/CibleImageset", *mBuffer.getActiveTexture()); 

   //then I create another Image with imageSet2 and I put It in a CEGUI::Window
    ...... 



My texture is the same. There is no change
I am lost ,Someone have an idea ?

Re: I want to make circle Image

Posted: Thu Dec 29, 2011 19:31
by Kulik
I am sorry if this offends you but I am not sure if you are trolling or what. :?

Are you just randomly writing code that incidentally compiles and expecting it to work like you want?

Read API docs of the methods. You are doing something completely different from what you want to be doing.

Re: I want to make circle Image

Posted: Fri Dec 30, 2011 13:59
by dragonblood
I post here to have some help, if you know how to do that why you're not helping me instead of make fun of me. I don't expect you to write all the code for me but I ask for an exemple.

Re: I want to make circle Image

Posted: Fri Dec 30, 2011 14:43
by saejox
if you are trying to create an 32bit image (RGB and alpha) use libPng. then load created image to cegui.
creating image pixel by pixel is not cegui's job.
check http://libpng.org/pub/png/libpng.html

Re: I want to make circle Image

Posted: Sat Jan 07, 2012 08:16
by dragonblood
saejox wrote:if you are trying to create an 32bit image (RGB and alpha) use libPng. then load created image to cegui.
creating image pixel by pixel is not cegui's job.
check http://libpng.org/pub/png/libpng.html

Ok, thanks to answer, I did'nt know there was impossible to do that in CEGUI...

Re: I want to make circle Image

Posted: Sun Jan 08, 2012 17:12
by Kulik
http://www.cegui.org.uk/docs/current/cl ... f475c20da2

Texture::loadFromMemory

CEGUI 0.8 (unreleased yet) also has texture blitting.