protected void _SetVertexInfoColor(PixelFormatDecoder.OutputPixel Color) { VertexInfo->R = (float)(Color.R) / 255.0f; VertexInfo->G = (float)(Color.G) / 255.0f; VertexInfo->B = (float)(Color.B) / 255.0f; VertexInfo->A = (float)(Color.A) / 255.0f; }
protected override void OnPaintBackground(PaintEventArgs PaintEventArgs) { if (IGuiExternalInterface.IsInitialized()) { if (EnableRefreshing) { try { Buffer.LockBitsUnlock(PixelFormat.Format32bppArgb, (BitmapData) => { int Width = 512; int Height = 272; var Count = Width * Height; var BitmapDataDecode = new PixelFormatDecoder.OutputPixel[Count]; fixed(PixelFormatDecoder.OutputPixel * BitmapDataDecodePtr = BitmapDataDecode) { var BitmapDataPtr = (BGRA *)BitmapData.Scan0.ToPointer(); var Address = PspDisplay.CurrentInfo.Address; //var Address = Memory.FrameBufferSegment.Low; //Console.WriteLine("{0:X}", Address); var FrameBuffer = (byte *)Memory.PspAddressToPointer(Address); //var LastRow = (FrameBuffer + 512 * 260 * 4 + 4 * 10); //Console.WriteLine("{0},{1},{2},{3}", LastRow[0], LastRow[1], LastRow[2], LastRow[3]); if (FrameBuffer == null) { Console.Error.WriteLine("FrameBuffer == null"); } else if (BitmapDataPtr == null) { Console.Error.WriteLine("BitmapDataPtr == null"); } else { PixelFormatDecoder.Decode( PspDisplay.CurrentInfo.PixelFormat, (void *)FrameBuffer, BitmapDataDecodePtr, Width, Height ); } // Converts the decoded data to Window's format. for (int n = 0; n < Count; n++) { BitmapDataPtr[n].R = BitmapDataDecodePtr[n].R; BitmapDataPtr[n].G = BitmapDataDecodePtr[n].G; BitmapDataPtr[n].B = BitmapDataDecodePtr[n].B; BitmapDataPtr[n].A = 0xFF; } } }); } catch (Exception Exception) { Console.WriteLine(Exception); } } //Console.WriteLine(this.ClientRectangle); PaintEventArgs.Graphics.CompositingMode = CompositingMode.SourceCopy; PaintEventArgs.Graphics.CompositingQuality = CompositingQuality.HighSpeed; PaintEventArgs.Graphics.InterpolationMode = InterpolationMode.NearestNeighbor; PaintEventArgs.Graphics.DrawImage( Buffer, new Rectangle( 0, menuStrip1.Height, 512 * DisplayScale, 272 * DisplayScale ) ); //PaintEventArgs.Graphics.DrawImageUnscaled(Buffer, new Point(0, menuStrip1.Height)); } else { var Buffer = new Bitmap(512, 272); var BufferGraphics = Graphics.FromImage(Buffer); BufferGraphics.FillRectangle(new SolidBrush(Color.Black), new Rectangle(0, 0, Buffer.Width, Buffer.Height)); //BufferGraphics.DrawString("Initializing...", new Font("Arial", 10), new SolidBrush(Color.White), new PointF(8, 8)); PaintEventArgs.Graphics.DrawImage(Buffer, new Rectangle(0, menuStrip1.Height, 512 * DisplayScale, 272 * DisplayScale)); } }