public static IImage Create(Pixbuf buf, BPP bpp) { byte[] data = new byte[buf.Height * buf.Width * (int)bpp]; IImage img = new IImage(bpp, buf.Width, buf.Height, data); if (bpp == BPP.Grayscale) { for (int y = 0; y < buf.Height; y++) { for (int x = 0; x < buf.Width; x++) { img[x, y] = (byte)Utility.GetPixel(buf, x, y); } } } else { for (int y = 0; y < buf.Height; y++) { for (int x = 0; x < buf.Width; x++) { img[x, y] = Utility.GetPixel(buf, x, y); } } } return(img); }
public IImage(BPP bpp, int w, int h) { this.bpp = bpp; this.w = w; this.h = h; data = new byte[w * h * (int)bpp]; }
public BmpImage(int width, int height, BPP bitsPerPixel) { Width = width; Height = height; BitsPerPixel = bitsPerPixel; RowPitch = (width * (int)bitsPerPixel / 32) * 4; Data = new byte[RowPitch * height]; }
private void RecreateImage(BPP bpp, int w, int h, byte[] data, bool copy) { this.bpp = bpp; this.w = w; this.h = h; if (copy) { this.data = new byte[w * h * (int)bpp]; for (int i = 0; i < w * h * (int)bpp; i++) { this.data[i] = data[i]; } } else { this.data = data; } }
public IImage(BPP bpp, int w, int h, byte[] data, bool copy) { RecreateImage(bpp, w, h, data, copy); }
public IImage(BPP bpp, int w, int h, byte[] data) { RecreateImage(bpp, w, h, data, false); }