Esempio n. 1
0
        protected Gdk.Pixbuf DrawAndConvert()
        {
            // Things like Padding needs to be set each time after Clear()
            plotSurface.SurfacePadding = padding;

            using (System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(bitmap_cache)) {
                plotSurface.Draw(g, rectSizing.Bounds);
                // draw frame
                g.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.None;
                g.DrawRectangle(framePen, 0, 0, rectSizing.Width - FrameWidth, rectSizing.Height - FrameWidth);
            }

            // Florence/NPlot library uses System.Drawing (.NET Base Class Library) types
            // have to convert result (System.Drawing.Bitmap) to Gdk.Pixbuf for Gtk usage

                        #if BitmapToPixbufConversionRaw
            return(PixbufFromBitmap(bitmap_cache));
                        #else
            if (memoryStream == null)
            {
                memoryStream = new System.IO.MemoryStream(MemoryStreamCapacity);
            }
            memoryStream.Position = 0;
            bitmap_cache.Save(memoryStream, imageFormat);
            memoryStream.Position = 0;
            return(new Gdk.Pixbuf(memoryStream));
                        #endif
        }
Esempio n. 2
0
        public void RedrawPlotSurface()
        {
            using (var graphics = Graphics.FromImage(plotBitmap))
            {
                graphics.CompositingQuality = CompositingQuality.HighQuality;
                graphics.InterpolationMode  = InterpolationMode.HighQualityBicubic;
                graphics.Clear(Color.White);

                plotSurface.Draw(graphics, new Rectangle(0, 0,
                                                         plotBitmap.Width, plotBitmap.Height));
            }

            // Update OpenGL texture
            Textures.Update(TextureId, plotBitmap);
        }