private unsafe void CopyToArgbAlpha8(SurfaceData surfaceData) { fixed(byte *dataPointer = data) fixed(ArgbColor * palettePointer = palette) { byte *destinationRowPointer = (byte *)surfaceData.DataPointer; byte *sourceColorPointer = dataPointer; byte *sourceAlphaPointer = dataPointer + Width * Height; for (int i = Height; i-- != 0; destinationRowPointer += surfaceData.Stride) { ArgbColor *destinationPointer = (ArgbColor *)destinationRowPointer; for (int j = Width; j-- != 0;) { ArgbColor.CopyWithAlpha(destinationPointer++, palettePointer + *sourceColorPointer++, *sourceAlphaPointer++); } } } }
private unsafe void CopyToArgbTransparent(SurfaceData surfaceData) { int rowLength = Width; fixed(byte *dataPointer = data) fixed(ArgbColor * palettePointer = palette) { byte *destinationRowPointer = (byte *)surfaceData.DataPointer; byte *sourcePointer = dataPointer; for (int i = Height; i-- != 0; destinationRowPointer += surfaceData.Stride) { ArgbColor *destinationPointer = (ArgbColor *)destinationRowPointer; for (int j = Width; j-- != 0;) { *destinationPointer++ = palettePointer[*sourcePointer++]; } } } }
protected unsafe override void CopyToArgbInternal(SurfaceData surfaceData) { switch (AlphaBitCount) { case 0: CopyToArgbOpaque(surfaceData); break; case 1: CopyToArgbAlpha1(surfaceData); break; case 4: CopyToArgbAlpha4(surfaceData); break; case 8: if (separateAlpha) { CopyToArgbAlpha8(surfaceData); } else { CopyToArgbTransparent(surfaceData); } break; default: throw new NotSupportedException(); // Should never happen… } }
protected override void CopyToArgbInternal(SurfaceData surfaceData) { throw new NotSupportedException(); }