public static Color Encode(ColorFormat ColorFormat, uint Value) { return Color.FromArgb( (int)(BitUtils.ExtractScaled(Value, ColorFormat.Alpha.Offset, ColorFormat.Alpha.Size, 255)), (int)(BitUtils.ExtractScaled(Value, ColorFormat.Red.Offset, ColorFormat.Red.Size, 255)), (int)(BitUtils.ExtractScaled(Value, ColorFormat.Green.Offset, ColorFormat.Green.Size, 255)), (int)(BitUtils.ExtractScaled(Value, ColorFormat.Blue.Offset, ColorFormat.Blue.Size, 255)) ); }
public PspBitmap(GuPixelFormats PixelFormat, int Width, int Height, byte* Address) { this.GuPixelFormat = PixelFormat; this.Width = Width; this.Height = Height; this.Address = Address; this.BitsPerPixel = PixelFormatDecoder.GetPixelsBits(PixelFormat); this.ColorFormat = PixelFormatDecoder.ColorFormatFromPixelFormat(PixelFormat); }
public PspBitmap(GuPixelFormats PixelFormat, int Width, int Height, byte* Address, int BytesPerLine = -1) { this.GuPixelFormat = PixelFormat; this.Width = Width; this.Height = Height; this.Address = Address; this.BitsPerPixel = PixelFormatDecoder.GetPixelsBits(PixelFormat); this.ColorFormat = PixelFormatDecoder.ColorFormatFromPixelFormat(PixelFormat); if (BytesPerLine < 0) { this.BytesPerLine = PixelFormatDecoder.GetPixelsSize(GuPixelFormat, Width); } else { this.BytesPerLine = BytesPerLine; } }
private void Read_Color_Component(String ComponentName, ColorFormat.Component ComponentInfo) { _SaveFloatField(ComponentName, () => { SafeILGenerator.LoadLocal(LocalColor); SafeILGenerator.Push((int)ComponentInfo.Offset); SafeILGenerator.BinaryOperation(SafeBinaryOperator.ShiftRightUnsigned); SafeILGenerator.Push((int)BitUtils.CreateMask(ComponentInfo.Size)); SafeILGenerator.BinaryOperation(SafeBinaryOperator.And); SafeILGenerator.ConvertTo<float>(); SafeILGenerator.Push((float)ComponentInfo.Mask); SafeILGenerator.BinaryOperation(SafeBinaryOperator.DivideSigned); }); }
private void Read_Color(ColorFormat ColorFormat) { _LoadIntegerAsInteger(Size: ColorFormat.TotalBytes, Signed: false); SafeILGenerator.StoreLocal(LocalColor); Read_Color_Component("Color.R", ColorFormat.Red); Read_Color_Component("Color.G", ColorFormat.Green); Read_Color_Component("Color.B", ColorFormat.Blue); Read_Color_Component("Color.A", ColorFormat.Alpha); }
public static uint Encode(this Color Color, ColorFormat Format) { return Format.Encode(Color.R, Color.G, Color.B, Color.A); }