public PixColor this[int index] { get { int color; if (Interop.LeptonicaApi.pixcmapGetColor32(handle, index, out color) == 0) { return(PixColor.FromRgb((uint)color)); } else { throw new InvalidOperationException("Failed to retrieve color."); } } set { if (Interop.LeptonicaApi.pixcmapResetColor(handle, index, value.Red, value.Green, value.Blue) != 0) { throw new InvalidOperationException("Failed to reset color."); } } }
private unsafe void TransferData32(PixData pixData, BitmapData imgData, int alphaMask) { var imgFormat = imgData.PixelFormat; var height = imgData.Height; var width = imgData.Width; for (var y = 0; y < height; y++) { var imgLine = ( byte * )imgData.Scan0 + (y * imgData.Stride); var pixLine = ( uint * )pixData.Data + (y * pixData.WordsPerLine); for (var x = 0; x < width; x++) { var pixVal = PixColor.FromRgba(pixLine[x]); var pixelPtr = imgLine + (x << 2); pixelPtr[0] = pixVal.Blue; pixelPtr[1] = pixVal.Green; pixelPtr[2] = pixVal.Red; pixelPtr[3] = ( byte )(alphaMask | pixVal.Alpha); // Allow user to include alpha or not } } }
public bool AddNewColor(PixColor color, out int index) { return(Interop.LeptonicaApi.pixcmapAddNewColor(handle, color.Red, color.Green, color.Blue, out index) == 0); }
public bool AddColor(PixColor color) { return(Interop.LeptonicaApi.pixcmapAddColor(handle, color.Red, color.Green, color.Blue) == 0); }
public static Color ToColor(this PixColor color) { return(Color.FromArgb(color.Alpha, color.Red, color.Green, color.Blue)); }
public bool AddNearestColor(PixColor color, out int index) => LeptonicaApi.Native.pixcmapAddNearestColor(this.Handle, color.Red, color.Green, color.Blue, out index) == 0;
public bool AddColor(PixColor color) => LeptonicaApi.Native.pixcmapAddColor(this.Handle, color.Red, color.Green, color.Blue) == 0;
public bool AddNearestColor(PixColor color, out int index) { return(LeptonicaApi.Native.pixcmapAddNearestColor(Handle, color.Red, color.Green, color.Blue, out index) == 0); }
public bool AddColor(PixColor color) { return(LeptonicaApi.Native.pixcmapAddColor(Handle, color.Red, color.Green, color.Blue) == 0); }
public bool AddColor(PixColor color) { return(LeptonicaPrimitives.Api.pixcmapAddColor(handle, color.Red, color.Green, color.Blue) == 0); }
public bool AddNewColor(PixColor color, out int index) { return(LeptonicaPrimitives.Api.pixcmapAddNewColor(handle, color.Red, color.Green, color.Blue, out index) == 0); }