public override void DrawImages(Image image, RectangleF[] destAndSrcPairs) { GLBitmap glBitmapTexture = image.InnerImage as GLBitmap; if (glBitmapTexture != null) { canvasGL2d.DrawGlyphImages(this.textColor, glBitmapTexture, destAndSrcPairs); } else { var currentInnerImage = image.InnerImage as System.Drawing.Bitmap; if (currentInnerImage != null) { //create and replace ? //TODO: add to another field image.InnerImage = glBitmapTexture = GLBitmapTextureHelper.CreateBitmapTexture(currentInnerImage); canvasGL2d.DrawGlyphImages(this.textColor, glBitmapTexture, destAndSrcPairs); } } }
public override void DrawImage(Image image, RectangleF destRect, RectangleF srcRect) { //copy from src to dest GLBitmap glBitmapTexture = image.InnerImage as GLBitmap; if (glBitmapTexture != null) { canvasGL2d.DrawImage(glBitmapTexture, srcRect, destRect.X, destRect.Y, destRect.Width, destRect.Height); } else { var currentInnerImage = image.InnerImage as System.Drawing.Bitmap; if (currentInnerImage != null) { //create and replace ? //TODO: add to another field image.InnerImage = glBitmapTexture = GLBitmapTextureHelper.CreateBitmapTexture(currentInnerImage); canvasGL2d.DrawImage(glBitmapTexture, srcRect, destRect.X, destRect.Y, destRect.Width, destRect.Height); } } }
public override void FillPolygon(Brush brush, PointF[] points) { canvasGL2d.Note1 = this.Note1; switch (brush.BrushKind) { case BrushKind.LinearGradient: { //linear grdient brush for polygon int j = points.Length; float[] polygonPoints = new float[j * 2]; int n = 0; for (int i = 0; i < j; ++i) { polygonPoints[n] = points[i].X; polygonPoints[n + 1] = points[i].Y; n += 2; } //use stencil buffer canvasGL2d.FillPolygon(brush, polygonPoints, polygonPoints.Length); } break; case BrushKind.Texture: { int j = points.Length; float[] polygonPoints = new float[j * 2]; int n = 0; for (int i = 0; i < j; ++i) { polygonPoints[n] = points[i].X; polygonPoints[n + 1] = points[i].Y; n += 2; } //use stencil buffer //prepare texture brush var tbrush = (TextureBrush)brush; GLBitmap bmpTexture = null; if (tbrush.InnerImage2 == null) { //create gl image var textureImage = tbrush.TextureImage; tbrush.InnerImage2 = bmpTexture = GLBitmapTextureHelper.CreateBitmapTexture((System.Drawing.Bitmap)textureImage.InnerImage); } canvasGL2d.FillPolygon(brush, polygonPoints, polygonPoints.Length); //delete gl bmpTexture.Dispose(); tbrush.InnerImage2 = null; } break; case BrushKind.Solid: { var solidColorBrush = (SolidBrush)brush; this.FillPolygon(solidColorBrush.Color, points); } break; default: { } break; } }
//------------------------------------------- public override void DrawImage(Image image, RectangleF destRect) { if (image.IsReferenceImage) { //use reference image GLBitmapReference bmpRef = image.InnerImage as GLBitmapReference; if (bmpRef != null) { canvasGL2d.DrawImage(bmpRef, destRect.X, destRect.Y); } else { var currentInnerImage = image.InnerImage as System.Drawing.Bitmap; if (currentInnerImage != null) { //create and replace ? //TODO: add to another field image.InnerImage = bmpRef = new GLBitmapReference( GLBitmapTextureHelper.CreateBitmapTexture(currentInnerImage), image.ReferenceX, image.ReferenceY, image.Width, image.Height); canvasGL2d.DrawImage(bmpRef, destRect.X, destRect.Y); } else { var currentGLImage = image.InnerImage as GLBitmap; if (currentGLImage != null) { bmpRef = new GLBitmapReference( currentGLImage, image.ReferenceX, image.ReferenceY, image.Width, image.Height); canvasGL2d.DrawImage(bmpRef, destRect.X, destRect.Y); } } } } else { GLBitmap glBitmapTexture = image.InnerImage as GLBitmap; if (glBitmapTexture != null) { canvasGL2d.DrawImage(glBitmapTexture, destRect.X, destRect.Y, destRect.Width, destRect.Height); } else { var currentInnerImage = image.InnerImage as System.Drawing.Bitmap; if (currentInnerImage != null) { //create and replace ? //TODO: add to another field image.InnerImage = glBitmapTexture = GLBitmapTextureHelper.CreateBitmapTexture(currentInnerImage); canvasGL2d.DrawImage(glBitmapTexture, destRect.X, destRect.Y, destRect.Width, destRect.Height); } } } }