Heman Image Lib

Share your helpful Urho3D code snippets, samples and tutorials here.

Heman Image Lib

PostPosted by Victor » 20 Oct 2016, 20:28

I just stumbled upon an interesting library for doing some advanced image manipulation. It can do some pretty cool stuff like making occlusion and normal maps.

Repo
https://github.com/prideout/heman

Documentation
http://heman.readthedocs.io/en/latest/

Here's a code snippet on converting image from heman -> Urho and Urho -> heman

Code: Select all
/// Convert heman image to Urho3D image.
void ImageHelper::ConvertHeman2Urho(Context* context, heman_image* image, Image*& result)
{
    for (int y = 0; y < image->height; y++) {
        for (int x = 0; x < image->width; x++) {
            kmVec3 color = *((kmVec3*) heman_image_texel(image, x, y));
            Color pixel(color.x, color.y, color.z);
            result->SetPixel(x, y, pixel);
        }
    }
}

// Convert image to Urho from heman
// (could be a heightmap so we check the nbands
void ImageHelper::ConvertUrho2Heman(Image* image, heman_image*& result)
{
    if (result->nbands == 3) {
        kmVec3* colors = (kmVec3*) result->data;

        for (int y = 0; y < image->GetHeight(); y++) {
            kmVec3* color = colors + y * result->width;

            for (int x = 0; x < image->GetWidth(); x++, color++) {
                Color pixel = image->GetPixel(x, y);
                color->x = pixel.r_;
                color->y = pixel.g_;
                color->z = pixel.b_;
            }
        }

        return;
    }

    float* colors = result->data;
    for (int y = 0; y < image->GetHeight(); y++) {
        float* color = colors + y * result->width;

        for (int x = 0; x < image->GetWidth(); x++, color++) {
            Color pixel = image->GetPixel(x, y);
            *color = pixel.r_;
        }
    }
}


Here's how I've used it in my Urho app:

Image
User avatar
Victor
Have some posts
Have some posts
 
Posts: 48
Joined: 11 May 2016, 14:22

Re: Heman Image Lib

PostPosted by TheSHEEEP » 21 Oct 2016, 06:08

By the power of Greyskull!
User avatar
TheSHEEEP
Have some posts
Have some posts
 
Posts: 27
Joined: 21 Jul 2016, 09:07
Location: Finland

Re: Heman Image Lib

PostPosted by namic » 10 Nov 2016, 20:54

Amazing library. Thanks for the info!
User avatar
namic
Some active
Some active
 
Posts: 64
Joined: 31 May 2015, 23:12


Return to Code Exchange

Who is online

Users browsing this forum: No registered users and 0 guests

cron