1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32:
| public static Bitmap GetImage(string source) { int imgName; Il.ilInit(); Ilu.iluInit(); Il.ilGenImages(1, out imgName);
Il.ilBindImage(imgName); Il.ilLoadImage(source); int width = Il.ilGetInteger(Il.IL_IMAGE_WIDTH); int height = Il.ilGetInteger(Il.IL_IMAGE_HEIGHT); int bpp = Il.ilGetInteger(Il.IL_IMAGE_BPP);
var ptr = Il.ilGetData(); Bitmap bmp = new Bitmap(width, height, width * 4, PixelFormat.Format32bppArgb, ptr); BitmapData bmpData = bmp.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height), ImageLockMode.ReadWrite, bmp.PixelFormat); Bitmap newBitmap = new Bitmap(width,height, bmpData.Stride, PixelFormat.Format32bppArgb, bmpData.Scan0);
bmp.UnlockBits(bmpData); bmp.Dispose(); Il.ilDeleteImages(1, ref imgName);
return newBitmap; }
Control.BackgroundImage = ... |