internal void WriteToImage(int bx, int by, Image <Rgba32> image) { LibJpegTools.ComponentData c0 = this.Components[0]; LibJpegTools.ComponentData c1 = this.Components[1]; LibJpegTools.ComponentData c2 = this.Components[2]; Block8x8 block0 = c0.SpectralBlocks[bx, by]; Block8x8 block1 = c1.SpectralBlocks[bx, by]; Block8x8 block2 = c2.SpectralBlocks[bx, by]; float d0 = (c0.MaxVal - c0.MinVal); float d1 = (c1.MaxVal - c1.MinVal); float d2 = (c2.MaxVal - c2.MinVal); for (int y = 0; y < 8; y++) { for (int x = 0; x < 8; x++) { float val0 = c0.GetBlockValue(block0, x, y); float val1 = c0.GetBlockValue(block1, x, y); float val2 = c0.GetBlockValue(block2, x, y); var v = new Vector4(val0, val1, val2, 1); Rgba32 color = default; color.PackFromVector4(v); int yy = by * 8 + y; int xx = bx * 8 + x; image[xx, yy] = color; } } }
public void PackUsingPointers() { Vector4 *sp = (Vector4 *)this.source.Pin(); byte * dp = (byte *)this.destination.Pin(); int count = this.Count; int size = sizeof(Rgba32); for (int i = 0; i < count; i++) { Vector4 v = Unsafe.Read <Vector4>(sp); Rgba32 c = default(Rgba32); c.PackFromVector4(v); Unsafe.Write(dp, c); sp++; dp += size; } }
internal void WriteToImage(int bx, int by, Image <Rgba32> image) { Block8x8 block = this.SpectralBlocks[bx, by]; for (int y = 0; y < 8; y++) { for (int x = 0; x < 8; x++) { float val = this.GetBlockValue(block, x, y); var v = new Vector4(val, val, val, 1); Rgba32 color = default; color.PackFromVector4(v); int yy = by * 8 + y; int xx = bx * 8 + x; image[xx, yy] = color; } } }