예제 #1
0
		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))
			);
		}
예제 #2
0
파일: PspBitmap.cs 프로젝트: e-COS/cspspemu
 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);
 }
예제 #3
0
 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;
     }
 }
예제 #4
0
 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);
     });
 }
예제 #5
0
 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);
 }
예제 #6
0
 public static uint Encode(this Color Color, ColorFormat Format)
 {
     return Format.Encode(Color.R, Color.G, Color.B, Color.A);
 }