Crystal Space
Welcome, Guest. Please login or register.
September 30, 2014, 09:29:45 pm

Login with username, password and session length
Search:     Advanced search
9020 Posts in 2053 Topics by 8556 Members
Latest Member: Boshyeng
* Home Help Search Login Register
+  Crystal Space
|-+  Crystal Space Development
| |-+  General Crystal Space Discussion
| | |-+  How to load an image? why I load an image but it's color became so strange?
« previous next »
Pages: [1] Print
Author Topic: How to load an image? why I load an image but it's color became so strange?  (Read 331 times)
Saomi
Newbie
*
Posts: 7


View Profile Email
« on: May 02, 2014, 11:39:32 am »

I load an Image like using this code in mygui:
Code:
void* CSOpenGLImageLoader::loadImage(int& _width, int& _height, MyGUI::PixelFormat& _format, const std::string& _filename)
{
    std::string fullPath = "/gui/" + _filename;

    csRef<iLoader> loader = csQueryRegistry<iLoader>(_app->GetObjectRegistry());
    csRef<iImage> img = loader->LoadImage(fullPath.c_str());

    if (img)
    {
        _width = img->GetWidth();
        _height = img->GetHeight();
        _format = MyGUI::PixelFormat::R8G8B8A8;

        csRef<iDataBuffer> buffer = img->GetRawData();
        void *ret = malloc(buffer->GetSize());
        memcpy(ret, buffer->GetData(), buffer->GetSize());

        return ret;
    }
    else
    {
        return 0;
    }
}
and my my image's color became so strange.
origin img:

loaded img:

I using MyGUI'S OpenGL render gui,
like this:
Code:
    _renderMgr->RenderView(_view);

    if (_isGUIVisible)
    {
        _glPlatform->getRenderManagerPtr()->drawOneFrame();
    }
Please help me!!thanks
Logged
Saomi
Newbie
*
Posts: 7


View Profile Email
« Reply #1 on: May 03, 2014, 10:58:42 am »

I load an Image like using this code in mygui:
Code:
void* CSOpenGLImageLoader::loadImage(int& _width, int& _height, MyGUI::PixelFormat& _format, const std::string& _filename)
{
    std::string fullPath = "/gui/" + _filename;

    csRef<iLoader> loader = csQueryRegistry<iLoader>(_app->GetObjectRegistry());
    csRef<iImage> img = loader->LoadImage(fullPath.c_str());

    if (img)
    {
        _width = img->GetWidth();
        _height = img->GetHeight();
        _format = MyGUI::PixelFormat::R8G8B8A8;

        csRef<iDataBuffer> buffer = img->GetRawData();
        void *ret = malloc(buffer->GetSize());
        memcpy(ret, buffer->GetData(), buffer->GetSize());

        return ret;
    }
    else
    {
        return 0;
    }
}
and my my image's color became so strange.
origin img:

loaded img:

I using MyGUI'S OpenGL render gui,
like this:
Code:
    _renderMgr->RenderView(_view);

    if (_isGUIVisible)
    {
        _glPlatform->getRenderManagerPtr()->drawOneFrame();
    }
Please help me!!thanks
Oh I had test it
and the image is load right´╝î
the problem is caused by the render,
and I had test it,
and now the problem is  why if I render the view,
and then I render my image using csSimplePixmap class,
it will can't dispaly,
but when I move the camera out of the mesh,
it will render the my image right,
which is the problem?
Logged
Pages: [1] Print 
« previous next »
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.2 | SMF © 2006-2007, Simple Machines LLC Valid XHTML 1.0! Valid CSS!
Page created in 5.224 seconds with 16 queries.