Users browsing this thread: 1 Guest(s)
Basics?
#10
Someone ought to fix code formatting, lol.
C# code example:
Code:
public static Bitmap Create(Color[] palette, byte[] indices, int width, int height)
{
    Bitmap bitmap = new Bitmap(width, height, PixelFormat.Format32bppArgb);
    for (int y = 0; y < height; y++)
    {
           // we traverse through the image from top to bottom
        for (int x = 0; x < width; x++)
        {
                        // ..and from left to right
                        // x + (y * width)] means we get the current column and
                        // add the amount of traversed rows * the amount of traversed columns
                        // in a 2-dimensional array, this would be equal to indices[x][y]
            bitmap.SetPixel(x, y, palette[indices[x + (y * width)]]);
                        // SetPixel() takes in the x and y coordinate and an ARGB Color value
        }
    }
    return bitmap;
}
Reply
Thanked by: Struggleton!


Messages In This Thread
Basics? - by Struggleton! - 07-23-2015, 07:45 AM
RE: Basics? - by puggsoy - 07-24-2015, 01:38 AM
RE: Basics? - by Struggleton! - 07-24-2015, 07:34 AM
RE: Basics? - by Struggleton! - 10-03-2015, 01:51 AM
RE: Basics? - by Vipershark - 10-03-2015, 01:59 AM
RE: Basics? - by Struggleton! - 10-03-2015, 02:39 AM
RE: Basics? - by puggsoy - 10-03-2015, 07:34 AM
RE: Basics? - by Struggleton! - 10-03-2015, 12:53 PM
RE: Basics? - by puggsoy - 10-03-2015, 11:28 PM
RE: Basics? - by TGE - 10-04-2015, 09:18 AM

Forum Jump: