public static void sampleBi(capex.image.RGBAPixelIntegerBuffer pixels, int x, int y, int[] color) { capex.image.ImageResizer.initFixedUnit(); var xscale = x & capex.image.ImageResizer.unit - 1; var yscale = y & capex.image.ImageResizer.unit - 1; var x0 = x >> capex.image.ImageResizer.FIXED_SHIFT; var y0 = y >> capex.image.ImageResizer.FIXED_SHIFT; var x1 = x0 + 1; var y1 = y0 + 1; var i = 0; var c0 = pixels.getRgbaPixel(x0, y0, true); var c1 = pixels.getRgbaPixel(x1, y0, true); var c2 = pixels.getRgbaPixel(x0, y1, true); var c3 = pixels.getRgbaPixel(x1, y1, true); color[3] = capex.image.ImageResizer.lerp(capex.image.ImageResizer.lerp(c0[3], c1[3], yscale), capex.image.ImageResizer.lerp(c2[3], c3[3], yscale), xscale); if (color[3] != 0) { for (i = 0; i < 3; i++) { color[i] = capex.image.ImageResizer.lerp(capex.image.ImageResizer.lerp(c0[i] * c0[3] / 255, c1[i] * c1[3] / 255, yscale), capex.image.ImageResizer.lerp(c2[i] * c2[3] / 255, c3[i] * c3[3] / 255, yscale), xscale); } } else { for (i = 0; i < 3; i++) { color[i] = 0; } } }
public byte[] getBufferRegion(int x, int y, bool newbuffer = false) { if (cache == null && newbuffer == false) { cache = new byte[rangew * rangeh * 4]; } var v = cache; if (newbuffer) { v = new byte[rangew * rangeh * 4]; } var p = v; if (p == null) { return(null); } var i = 0; var j = 0; for (i = 0; i < rangeh; i++) { for (j = 0; j < rangew; j++) { var pix = src.getRgbaPixel(x + j, y + i); cape.Buffer.setByte(p, (long)((i * rangew + j) * 4 + 0), (byte)pix[0]); cape.Buffer.setByte(p, (long)((i * rangew + j) * 4 + 1), (byte)pix[1]); cape.Buffer.setByte(p, (long)((i * rangew + j) * 4 + 2), (byte)pix[2]); cape.Buffer.setByte(p, (long)((i * rangew + j) * 4 + 3), (byte)pix[3]); } } return(v); }