use IrrlichtLime convert graycale to RGB

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
Sharon1105
Posts: 5
Joined: Mon Apr 09, 2012 1:37 am

use IrrlichtLime convert graycale to RGB

Post by Sharon1105 »

Hi all,

I want to convert a grayscale bitmap to a color bitmap without using a color diagram.
I'm facing the problem of convert "IrrlichtLime.Video.ColorHSL" to "system.drawing.color"
Here is part of my code ...

Code: Select all

private void button2_Click(object sender, EventArgs e)
        {
            Bitmap bmp = (Bitmap)pictureBox1.Image;
            int NumRow = pictureBox1.Height;
            int numCol = pictureBox1.Width;
            Bitmap color = new Bitmap(pictureBox1.Width, pictureBox1.Height);// COLOR is the resultant matrix 
            for (int i = 0; i < NumRow; i++)
            {
                for (int j = 0; j < numCol; j++)
                {
                    System.Drawing.Color need = bmp.GetPixel(j, i);
                    int use = need.R;
                    IrrlichtLime.Video.ColorHSL clr = new IrrlichtLime.Video.ColorHSL(use,255,127);
                    
                    color.SetPixel(j, i, clr); //error appears cannot convert 'Irrlicht.video.colorHSL' to 'system.drawing.color'
                    
                     
                }
            }
            pictureBox1.Image = color;
        }
Please help...Thanks!
greenya
Posts: 1012
Joined: Sun Jan 21, 2007 1:46 pm
Location: Ukraine
Contact:

Re: use IrrlichtLime convert graycale to RGB

Post by greenya »

Before next line

Code: Select all

color.SetPixel(j, i, clr); //error appears cannot convert 'Irrlicht.video.colorHSL' to 'system.drawing.color'
you should convert type first and use it (a proper type):

Code: Select all

System.Drawing.Color clr2 = System.Drawing.Color.FromArgb((int)clr.ToColor().ARGB);
and now use clr2 instead of clr.

BUT it will not work as you might expect, because of the way how you create ColorHSL:

Code: Select all

new IrrlichtLime.Video.ColorHSL(use,255,127);
check the docs, and the value range you pass.

Code: Select all

//
// Summary:
//     Creates a color using hue, saturation and luminance.
//
// Parameters:
//   hue:
//     Hue value. Must be value between 0.0f and 360.0f.
//
//   saturation:
//     Saturation value. Must be value between 0.0f and 100.0f.
//
//   luminance:
//     Luminance value. Must be value between 0.0f and 100.0f.
public ColorHSL(float hue, float saturation, float luminance);
Sharon1105
Posts: 5
Joined: Mon Apr 09, 2012 1:37 am

Re: use IrrlichtLime convert graycale to RGB

Post by Sharon1105 »

Thanks so much Greenya! It works perfect.

I change the value of this line
new IrrlichtLime.Video.ColorHSL(use,100,50);
and i get excatly what i want!
Post Reply