Creating an Image Label from Buffer

This example demonstrates how to create an image label from a memory buffer. This example uses the ICreator80 (CreatePosition, CreateImageLabelFromBuffer, CreateLabelStyle) methods.

 

var image = System.Drawing.Image.FromFile(C:\\sample.png);

Bitmap bmp = (Bitmap)image;

var ms = new MemoryStream();

image.Save(ms, image.RawFormat);

            System.Drawing.ImageConverter ic = newSystem.Drawing.ImageConverter();

 

Int32[] dwordArr = newInt32[bmp.Width * bmp.Height];

            for(intj = 0; j<bmp.Height; j++)

            {

                for(inti = 0; i<bmp.Width; i++)

                {

                    Color c = bmp.GetPixel(i, j);

dwordArr[(j * bmp.Width) + i] = (Int32) ((c.R << 0) | (c.G << 8) | (c.B << 16) | (c.A << 24));

                }

            }

            ITerrainImageLabel80 labelFromMemory = sgworld80.Creator.CreateImageLabelFromBuffer(sgworld80.Creator.CreatePosition(0, 0, 100), dwordArr, bmp.Width, bmp.Height, sgworld80.Creator.CreateLabelStyle());