GLBitmap ConvertFromBGRA_To_RGBA(GLBitmap bgraBmp) { GLBitmap rgba_result = new GLBitmap(bgraBmp.Width, bgraBmp.Height);//create another from blank with the same size using (GLRenderSurface surface1 = new GLRenderSurface(bgraBmp.Width, bgraBmp.Height)) using (GLRenderSurface surface2 = new GLRenderSurface(rgba_result, false)) { _pcx.AttachToRenderSurface(surface1); _pcx.OriginKind = PixelFarm.Drawing.RenderSurfaceOriginKind.LeftTop; //------------------------------------------------------------------------------------ //after make the frameBuffer current //then all drawing command will apply to frameBuffer //do draw to frame buffer here _pcx.Clear(PixelFarm.Drawing.Color.Black); _pcx.DrawImage(bgraBmp, 0, 0); //------------------------------------------------------------------------------------ _pcx.AttachToRenderSurface(null); //after release current, we move back to default frame buffer again*** _pcx.AttachToRenderSurface(surface2); _pcx.OriginKind = PixelFarm.Drawing.RenderSurfaceOriginKind.LeftTop; _pcx.Clear(PixelFarm.Drawing.Color.Black); _pcx.DrawImage(surface1.GetGLBitmap(), 0, 0); _pcx.AttachToRenderSurface(null); } return(rgba_result); }
protected override void OnGLRender(object sender, EventArgs args) { _pcx.SmoothMode = SmoothMode.Smooth; _pcx.StrokeColor = PixelFarm.Drawing.Color.Blue; _pcx.Clear(PixelFarm.Drawing.Color.White); _pcx.ClearColorBuffer(); //------------------------------- _pcx.OriginKind = PixelFarm.Drawing.RenderSurfaceOriginKind.LeftTop; if (!_isInit) { _glbmp = DemoHelper.LoadTexture(RootDemoPath.Path + @"\logo-dark.png"); _isInit = true; } if (_surface1.IsValid) { if (_frameBufferNeedUpdate) { //------------------------------------------------------------------------------------ //framebuffer _pcx.OriginKind = PixelFarm.Drawing.RenderSurfaceOriginKind.LeftTop; _pcx.AttachToRenderSurface(_surface1); //after make the frameBuffer current //then all drawing command will apply to frameBuffer //do draw to frame buffer here _pcx.Clear(PixelFarm.Drawing.Color.Red); _pcx.DrawImageWithBlurX(_glbmp, 0, 0); _pcx.AttachToRenderSurface(null);//switch to primary render surface //------------------------------------------------------------------------------------ //framebuffer2 _pcx.AttachToRenderSurface(_surface2); _pcx.OriginKind = PixelFarm.Drawing.RenderSurfaceOriginKind.LeftTop; //GLBitmap bmp2 = new GLBitmap(_frameBuffer.TextureId, _frameBuffer.Width, _frameBuffer.Height); //bmp2.IsYFlipped = true; //bmp2.IsBigEndianPixel = true; _pcx.DrawImageWithBlurY(_surface1.GetGLBitmap(), 0, 0); _pcx.AttachToRenderSurface(null); //------------------------------------------------------------------------------------ //after release current, we move back to default frame buffer again*** _frameBufferNeedUpdate = false; } _pcx.DrawImage(_surface2.GetGLBitmap(), 0, 0); //_pcx.DrawFrameBuffer(_frameBuffer2, 0, 0, true); } else { _pcx.Clear(PixelFarm.Drawing.Color.Blue); } //------------------------------- SwapBuffers(); }
protected override void OnGLRender(object sender, EventArgs args) { _pcx.SmoothMode = SmoothMode.Smooth; _pcx.StrokeColor = PixelFarm.Drawing.Color.Blue; _pcx.Clear(PixelFarm.Drawing.Color.White); //set clear color and clear all buffer _pcx.ClearColorBuffer(); //test , clear only color buffer //------------------------------- if (!_isInit) { _glbmp = DemoHelper.LoadTexture(RootDemoPath.Path + @"\logo-dark.jpg"); _isInit = true; } PixelFarm.Drawing.RenderSurfaceOriginKind prevOrgKind = _pcx.OriginKind; //save _pcx.OriginKind = PixelFarm.Drawing.RenderSurfaceOriginKind.LeftTop; if (_surface1.IsValid) { if (_frameBufferNeedUpdate) { _pcx.AttachToRenderSurface(_surface1); _pcx.OriginKind = PixelFarm.Drawing.RenderSurfaceOriginKind.LeftTop; //------------------------------------------------------------------------------------ //after make the frameBuffer current //then all drawing command will apply to frameBuffer //do draw to frame buffer here _pcx.Clear(PixelFarm.Drawing.Color.Black); _pcx.DrawImage(_glbmp, 5, 5); //------------------------------------------------------------------------------------ _pcx.AttachToRenderSurface(null); //after release current, we move back to default frame buffer again*** _frameBufferNeedUpdate = false; } _pcx.OriginKind = PixelFarm.Drawing.RenderSurfaceOriginKind.LeftTop; //_pcx.DrawFrameBuffer(_frameBuffer, 0, 0, true); for (int i = 0; i < 1; ++i) { _pcx.DrawImage(_surface1.GetGLBitmap(), 100 + (i * 30), 200 + (i * 30)); } } else { _pcx.Clear(PixelFarm.Drawing.Color.Blue); } //------------------------------- _pcx.OriginKind = prevOrgKind;//restore }
protected override void OnGLRender(object sender, EventArgs args) { _pcx.SmoothMode = SmoothMode.Smooth; _pcx.StrokeColor = PixelFarm.Drawing.Color.Blue; _pcx.Clear(PixelFarm.Drawing.Color.White); _pcx.ClearColorBuffer(); //------------------------------- if (!_isInit) { _glbmp = DemoHelper.LoadTexture(RootDemoPath.Path + @"\leaves.jpg"); _isInit = true; } if (_surface1.IsValid) { if (_frameBufferNeedUpdate) { //------------------------------------------------------------------------------------ //framebuffer _pcx.AttachToRenderSurface(_surface1); //after make the frameBuffer current //then all drawing command will apply to frameBuffer //do draw to frame buffer here _pcx.Clear(PixelFarm.Drawing.Color.Red); _pcx.DrawImageWithConv3x3(_glbmp, Mat3x3ConvGen.emboss, 0, 0); _pcx.AttachToRenderSurface(null); //after release current, we move back to default frame buffer again*** _frameBufferNeedUpdate = false; } //_pcx.DrawFrameBuffer(_frameBuffer, 0, 0, true); _pcx.DrawImage(_surface1.GetGLBitmap(), 0, 0); } else { _pcx.Clear(PixelFarm.Drawing.Color.Blue); } //------------------------------- SwapBuffers(); }
protected override void OnGLRender(object sender, EventArgs args) { //reset _pcx.SmoothMode = SmoothMode.Smooth; _pcx.ClearColorBuffer(); _painter.Clear(Color.Yellow); switch (DrawSet) { case T408_DrawSet.A: { //draw msdf bitmap to mask surface if (_maskRenderSurface == null) { GLRenderSurface currentSurface = _pcx.CurrentRenderSurface; _maskRenderSurface = new GLRenderSurface(100, 100); _pcx.AttachToRenderSurface(_maskRenderSurface); //draw mask _pcx.Clear(Color.Black); _pcx.DrawImageWithMsdf(_msdfMaskGLBmp, 0, 0, 5, Color.White); //switch back to normal surface _pcx.AttachToRenderSurface(currentSurface); } //render with simple mask _pcx.DrawImageWithMask( _maskRenderSurface.GetInnerGLData().GLBmp, _colorGLBmp, 0, 0); } break; case T408_DrawSet.B: { RectangleF maskSrc = new RectangleF(0, 0, _msdfMaskBmp.Width, _msdfMaskBmp.Height); Rectangle rect = new Rectangle(10, 10, 120, 120); Quad2f quad = new Quad2f(); quad.SetCornersFromRect(rect); AffineMat mat1 = AffineMat.Iden(); mat1.Translate(-rect.Width / 2, -rect.Height / 2); mat1.RotateDeg(45); mat1.Translate(rect.Width / 2, rect.Height / 2); quad.Transform(mat1); //***test transform //----------------------- //create mask surface, this quite low leve step. //user should use this through drawboard //----------------------- if (_maskRenderSurface2 == null) { //before we switch to another GLRenderSurface. //we save current setting of current GLRenderSurface _pcx.SaveStates(out GLPainterStatesData saveData1); _maskRenderSurface2 = new GLRenderSurface(100, 100); _pcx.AttachToRenderSurface(_maskRenderSurface2); _pcx.OriginKind = PixelFarm.Drawing.RenderSurfaceOriginKind.LeftTop; //draw mask _pcx.Clear(Color.Black); //draw image to specific quad _pcx.DrawImageWithMsdf(_msdfMaskGLBmp, quad, Color.White); //switch back to normal surface _pcx.RestoreStates(saveData1); } _pcx.DrawImageWithMask( _maskRenderSurface2.GetInnerGLData().GLBmp, _colorGLBmp, 20, 20); } break; } SwapBuffers(); }