I want to make circle Image

For help with general CEGUI usage:
- Questions about the usage of CEGUI and its features, if not explained in the documentation.
- Problems with the CMAKE configuration or problems occuring during the build process/compilation.
- Errors or unexpected behaviour.

Moderators: CEGUI MVP, CEGUI Team

dragonblood
Just popping in
Just popping in
Posts: 17
Joined: Mon Dec 05, 2011 13:23

I want to make circle Image

Postby dragonblood » Fri Dec 16, 2011 20:20

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+

Jamarr
CEGUI MVP
CEGUI MVP
Posts: 812
Joined: Tue Jun 03, 2008 23:59
Location: USA

Re: I want to make circle Image

Postby Jamarr » Wed Dec 21, 2011 17:41

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!
If somebody helps you by replying to your thread, upvote him/her as a thanks! Make sure to include your CEGUI.log and everything you tried when posting! And remember that we are not magicians!

dragonblood
Just popping in
Just popping in
Posts: 17
Joined: Mon Dec 05, 2011 13:23

Re: I want to make circle Image

Postby dragonblood » Sun Dec 25, 2011 17:57

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

Jamarr
CEGUI MVP
CEGUI MVP
Posts: 812
Joined: Tue Jun 03, 2008 23:59
Location: USA

Re: I want to make circle Image

Postby Jamarr » Tue Dec 27, 2011 17:35

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.
If somebody helps you by replying to your thread, upvote him/her as a thanks! Make sure to include your CEGUI.log and everything you tried when posting! And remember that we are not magicians!

dragonblood
Just popping in
Just popping in
Posts: 17
Joined: Mon Dec 05, 2011 13:23

Re: I want to make circle Image

Postby dragonblood » Tue Dec 27, 2011 20:43

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 ?

User avatar
Kulik
CEGUI Team
Posts: 1382
Joined: Mon Jul 26, 2010 18:47
Location: Czech Republic
Contact:

Re: I want to make circle Image

Postby Kulik » Tue Dec 27, 2011 21:05

I don't understand what's your problem really.

Do you know the concept of alpha transparency?

dragonblood
Just popping in
Just popping in
Posts: 17
Joined: Mon Dec 05, 2011 13:23

Re: I want to make circle Image

Postby dragonblood » Tue Dec 27, 2011 21:13

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 ?

User avatar
Kulik
CEGUI Team
Posts: 1382
Joined: Mon Jul 26, 2010 18:47
Location: Czech Republic
Contact:

Re: I want to make circle Image

Postby Kulik » Tue Dec 27, 2011 21:48

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?

dragonblood
Just popping in
Just popping in
Posts: 17
Joined: Mon Dec 05, 2011 13:23

Re: I want to make circle Image

Postby dragonblood » Wed Dec 28, 2011 18:47

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 ?

User avatar
Kulik
CEGUI Team
Posts: 1382
Joined: Mon Jul 26, 2010 18:47
Location: Czech Republic
Contact:

Re: I want to make circle Image

Postby Kulik » Thu Dec 29, 2011 19:31

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.

dragonblood
Just popping in
Just popping in
Posts: 17
Joined: Mon Dec 05, 2011 13:23

Re: I want to make circle Image

Postby dragonblood » Fri Dec 30, 2011 13:59

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.
Last edited by dragonblood on Fri Dec 30, 2011 17:14, edited 1 time in total.

saejox
Just popping in
Just popping in
Posts: 8
Joined: Sun Nov 20, 2011 18:17

Re: I want to make circle Image

Postby saejox » Fri Dec 30, 2011 14:43

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

dragonblood
Just popping in
Just popping in
Posts: 17
Joined: Mon Dec 05, 2011 13:23

Re: I want to make circle Image

Postby dragonblood » Sat Jan 07, 2012 08:16

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...

User avatar
Kulik
CEGUI Team
Posts: 1382
Joined: Mon Jul 26, 2010 18:47
Location: Czech Republic
Contact:

Re: I want to make circle Image

Postby Kulik » Sun Jan 08, 2012 17:12

http://www.cegui.org.uk/docs/current/cl ... f475c20da2

Texture::loadFromMemory

CEGUI 0.8 (unreleased yet) also has texture blitting.


Return to “Help”

Who is online

Users browsing this forum: No registered users and 4 guests