CSPspEmu.Core.Utils.PspBitmap.SetPixel C# (CSharp) Method

SetPixel() public method

public SetPixel ( int X, int Y, OutputPixel Color ) : void
X int
Y int
Color OutputPixel
return void
        public void SetPixel(int X, int Y, OutputPixel Color)
        {
            if (!IsValidPosition(X, Y)) return;
            //var Position = PixelFormatDecoder.GetPixelsSize(GuPixelFormat, Y * Width + X);
            var Position = GetOffset(X, Y);
            uint Value = this.ColorFormat.Encode(Color);
            switch (this.BitsPerPixel)
            {
                case 16: *(ushort*)(Address + Position) = (ushort)Value; break;
                case 32: *(uint*)(Address + Position) = (uint)Value; break;
                default: throw(new NotImplementedException());
            }
        }

Usage Example

Beispiel #1
0
        public int sceFontGetCharGlyphImage_Clip(FontHandle FontHandle, ushort CharCode, GlyphImage* GlyphImagePointer, int ClipX, int ClipY, int ClipWidth, int ClipHeight)
        {
            var Font = Fonts.Get(FontHandle);
            var Glyph = Font.GetGlyph(CharCode);
            var Face = Glyph.Face;
            var PixelFormat = GlyphImagePointer->PixelFormat;
            var Buffer = PspMemory.PspAddressToPointerSafe(GlyphImagePointer->Buffer);
            var BufferHeight = GlyphImagePointer->BufferHeight;
            var BufferWidth = GlyphImagePointer->BufferWidth;
            var Position = GlyphImagePointer->Position;
            var GlyphBitmap = Face.GetBitmap();
            var OutputBitmap = new PspBitmap(PixelFormat, (int)BufferWidth, (int)BufferHeight, (byte*)Buffer);

            try
            {
                for (int y = 0; y < ClipHeight; y++)
                {
                    for (int x = 0; x < ClipWidth; x++)
                    {
                        //Console.WriteLine();
                        OutputBitmap.SetPixel(x, y, new OutputPixel(GlyphBitmap.GetPixel(x + ClipX, y + ClipY)));
                        //OutputBitmap.SetPixel(x, y, new OutputPixel(Color.Red));
                    }
                }
            }
            catch (Exception Exception)
            {
                Console.Error.WriteLine(Exception);
            }

            //for (int n = 0; n < )
            //Console.Error.WriteLine("'{0}': {1}", (char)CharCode, Glyph);
            //throw (new NotImplementedException());
            return 0;
        }