当前位置: 首页>>代码示例>>C#>>正文


C# IGraphics.DrawImageUnscaled方法代码示例

本文整理汇总了C#中IGraphics.DrawImageUnscaled方法的典型用法代码示例。如果您正苦于以下问题:C# IGraphics.DrawImageUnscaled方法的具体用法?C# IGraphics.DrawImageUnscaled怎么用?C# IGraphics.DrawImageUnscaled使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IGraphics的用法示例。


在下文中一共展示了IGraphics.DrawImageUnscaled方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: PaintSecondMark

 private void PaintSecondMark(IGraphics g, int scrollBarWid, int width)
 {
     if (secondMark == null){
         CreateSecondMark(scrollBarWid);
     }
     int h = scrollBarWid - 1;
     switch (state){
         case ScrollBarState.HighlightSecondBox:
             g.DrawImageUnscaled(secondMarkHighlight, width - h, 1);
             break;
         case ScrollBarState.PressSecondBox:
             g.DrawImageUnscaled(secondMarkPress, width - h, 1);
             break;
         default:
             g.DrawImageUnscaled(secondMark, width - h, 1);
             break;
     }
 }
开发者ID:neuhauser,项目名称:compbio-base,代码行数:18,代码来源:HorizontalScrollBarView.cs

示例2: PaintBar

 private void PaintBar(IGraphics g, int scrollBarWid, int width)
 {
     if (!HasBar){
         return;
     }
     if (bar != null && CalcBarSize(width) != bar.Width){
         bar = null;
     }
     if (bar == null){
         CreateBar(scrollBarWid, width);
     }
     int h = CalcBarStart(width);
     switch (state){
         case ScrollBarState.HighlightBar:
             g.DrawImageUnscaled(barHighlight, h, 1);
             break;
         case ScrollBarState.PressBar:
             g.DrawImageUnscaled(barPress, h, 1);
             break;
         default:
             g.DrawImageUnscaled(bar, h, 1);
             break;
     }
 }
开发者ID:neuhauser,项目名称:compbio-base,代码行数:24,代码来源:HorizontalScrollBarView.cs

示例3: PaintFirstMark

 private void PaintFirstMark(IGraphics g, int scrollBarWid)
 {
     if (firstMark == null){
         CreateFirstMark(scrollBarWid);
     }
     switch (state){
         case ScrollBarState.HighlightFirstBox:
             g.DrawImageUnscaled(firstMarkHighlight, 0, 1);
             break;
         case ScrollBarState.PressFirstBox:
             g.DrawImageUnscaled(firstMarkPress, 0, 1);
             break;
         default:
             g.DrawImageUnscaled(firstMark, 0, 1);
             break;
     }
 }
开发者ID:neuhauser,项目名称:compbio-base,代码行数:17,代码来源:HorizontalScrollBarView.cs

示例4: OnRenderInternal

 /// <summary>
 /// Function that does the actual rendering
 /// </summary>
 /// <param name="pt">The point</param>
 /// <param name="g">The graphics object</param>
 internal override void OnRenderInternal(PointF ptf, IGraphics g)
 {
     Point pt = new Point(
         Convert.ToInt32(ptf.X), 
         Convert.ToInt32(ptf.Y));
     Image symbol = Symbol ?? DefaultSymbol;
     int width = Convert.ToInt32(symbol.Width * Scale);
     int height = Convert.ToInt32(symbol.Height * Scale);
     if (ImageAttributes == null)
     {
         if (Scale == 1f)
         {
             lock (symbol)
             {
                 g.DrawImageUnscaled(symbol, pt.X, pt.Y);
             }
         }
         else
         {
             lock (symbol)
             {
                 g.DrawImage(
                     symbol,
                     pt.X,
                     pt.Y,
                     width,
                     height);
             }
         }
     }
     else
     {
         g.DrawImage(
             symbol,
             pt.X, pt.Y, width, height,
             0, 0, symbol.Width, symbol.Height,
             GraphicsUnitType.Pixel,
             ImageAttributes);
     }
 }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:45,代码来源:RasterPointSymbolizer.cs

示例5: PaintOnGraphicsBitmap

 protected void PaintOnGraphicsBitmap(IGraphics g, int width, int height)
 {
     if (backBuffer == null || scatterPlot == null) {
         return;
     }
     UnsafeBitmap copyBackBuffer = new UnsafeBitmap(backBuffer);
     copyBackBuffer.LockBitmap();
     // selected data-points
     foreach (int s in scatterPlot.Selection) {
         double[] w = scatterPlot.GetDataAt(s);
         if (w.Length > 0){
             double x = w[0];
             double y = w[1];
             SymbolProperties gx = GetPointProperties != null ? GetPointProperties(s) : defaultSymbol;
             SymbolType symbolType = SymbolType.allSymbols[gx.Type];
             int symbolSize = gx.Size;
             if (symbolSize > 0){
                 int[] pathX;
                 int[] pathY;
                 symbolType.GetPath(symbolSize, out pathX, out pathY);
                 copyBackBuffer.DrawPath(SelectionColor, ModelToViewX(x, width), ModelToViewY(y, height), pathX, pathY);
             }
         }
     }
     copyBackBuffer.UnlockBitmap();
     // labels
     ScatterPlotLabelMode labelMode = scatterPlot.GetLabelMode();
     bool cutLabels = scatterPlot.CutLabels;
     if (labelMode == ScatterPlotLabelMode.All && scatterPlot.HasLabels) {
         Font font = new Font("Arial", scatterPlot.FontSize, scatterPlot.FontStyle);
         for (;;){
             double[] x;
             double[] y;
             double[] z;
             string[] labels;
             int index;
             try{
                 scatterPlot.GetData(out x, out y, out z, out labels, out index);
             } catch (IndexOutOfRangeException){
                 break;
             }
             if (x == null){
                 break;
             }
             SymbolProperties gx = GetPointProperties != null ? GetPointProperties(index) : defaultSymbol;
             for (int i = 0; i < x.Length; i++){
                 if (labelMode == ScatterPlotLabelMode.All || scatterPlot.IsSelected(i)) {
                     int ix = ModelToViewX(x[i], width);
                     int iy = ModelToViewY(y[i], height);
                     Color c;
                     if (z != null && colorScale != null){
                         c = colorScale.GetColor(z[i]);
                     } else{
                         c = gx.Color;
                     }
                     Brush b = new SolidBrush(c);
                     if (ix >= 0 && iy >= 0 && ix < width && iy < height){
                         if (labels[i] != null){
                             string s = labels[i];
                             if (cutLabels){
                                 if (s.Contains(";")){
                                     s = s.Substring(0, s.IndexOf(';'));
                                 }
                             }
                             copyBackBuffer.DrawString(s, font, b, ix, iy);
                         }
                     }
                 }
             }
         }
         scatterPlot.Reset();
     }
     if (labelMode == ScatterPlotLabelMode.Selected && scatterPlot.HasLabels) {
         Brush br = new SolidBrush(SelectionColor);
         Font font = new Font("Arial", scatterPlot.FontSize, scatterPlot.FontStyle);
         foreach (int s in scatterPlot.Selection) {
             double[] w = scatterPlot.GetDataAt(s);
             string label = scatterPlot.GetLabelAt(s);
             double x = w[0];
             double y = w[1];
             int ix = ModelToViewX(x, width);
             int iy = ModelToViewY(y, height);
             if (ix >= 0 && iy >= 0 && ix < width && iy < height){
                 if (label != null){
                     if (cutLabels){
                         if (label.Contains(";")){
                             label = label.Substring(0, label.IndexOf(';'));
                         }
                     }
                     copyBackBuffer.DrawString(label, font, br, ix, iy);
                 }
             }
         }
     }
     // draw the image
     g.DrawImageUnscaled(copyBackBuffer.Bitmap, 0, 0);
     copyBackBuffer.Dispose();
     g.SmoothingMode = SmoothingMode.AntiAlias;
     DrawPolygons(g, width, height);
     if (drawFunctions != null){
//.........这里部分代码省略.........
开发者ID:neuhauser,项目名称:compbio-base,代码行数:101,代码来源:ScatterPlotPlaneView.cs

示例6: RenderParellel

        private void RenderParellel(IGraphics g)
        {
            _images = new Image[_layers.Length];

            var res = Parallel.For(0, _layers.Length, RenderToImage);
            
            var tmpTransform = g.Transform;
            g.Transform = new Matrix();
            if (res.IsCompleted)
            {
                for (var i = 0; i < _images.Length; i++)
                {
                    if (_images[i] != null)
                    {
                        g.DrawImageUnscaled(_images[i], 0, 0);
                        //break;
                    }
                }
            }
            g.Transform = tmpTransform;
        }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:21,代码来源:LayerCollectionRenderer.cs

示例7: Render

        /// <summary>
        /// Renders the layer
        /// </summary>
        /// <param name="graphics">Graphics object reference</param>
        /// <param name="map">Map which is rendered</param>
        public override void Render(IGraphics graphics, Map map)
        {
            if (!map.Size.IsEmpty && map.Size.Width > 0 && map.Size.Height > 0)
            {
                var bmp = new Bitmap(map.Size.Width, map.Size.Height, PixelFormat.Format32bppArgb);
                
                using (IGraphics g = Graphics.FromImage(bmp).G())
                {
                    g.InterpolationMode = InterpolationMode;
                    g.Transform = graphics.Transform.Clone();

                    var extent = new Extent(map.Envelope.MinX, map.Envelope.MinY, 
                                            map.Envelope.MaxX, map.Envelope.MaxY);
                    var level = BruTile.Utilities.GetNearestLevel(_source.Schema.Resolutions, map.PixelSize);
                    var tiles = new List<TileInfo>(_source.Schema.GetTilesInView(extent, level));
                    var tileWidth = _source.Schema.GetTileWidth(level);
                    var tileHeight = _source.Schema.GetTileWidth(level);

                    IList<WaitHandle> waitHandles = new List<WaitHandle>();
                    var toRender = new Dictionary<TileIndex, Bitmap>();
                    var takenFromCache = new Dictionary<TileIndex,bool>();
                    foreach (TileInfo info in tiles)
                    {
                        var image = _bitmaps.Find(info.Index);
                        if (image != null)
                        {
                            toRender.Add(info.Index, image);
                            takenFromCache.Add(info.Index,true);
                            continue;
                        }
                        if (_fileCache != null && _fileCache.Exists(info.Index))
                        {
                            _bitmaps.Add(info.Index, GetImageFromFileCache(info) as Bitmap);
                            toRender.Add(info.Index, _bitmaps.Find(info.Index));
                            takenFromCache.Add(info.Index,true);
                            continue;
                        }

                        var waitHandle = new AutoResetEvent(false);
                        waitHandles.Add(waitHandle);
                        ThreadPool.QueueUserWorkItem(GetTileOnThread,
                                                     new object[] { _source.Provider, info, toRender, waitHandle, true });
                    }

                    foreach (var handle in waitHandles)
                        handle.WaitOne();

                    using (var ia = new ImageAttributes())
                    {
                        if (!_transparentColor.IsEmpty)
                            ia.SetColorKey(_transparentColor, _transparentColor);
#if !PocketPC
                        ia.SetWrapMode(WrapMode.TileFlipXY);
#endif

                        foreach (var info in tiles)
                        {
                            if (!toRender.ContainsKey(info.Index))
                                continue;

                            var bitmap = toRender[info.Index];//_bitmaps.Find(info.Index);
                            if (bitmap == null) continue;

                            var min = map.WorldToImage(new Coordinate(info.Extent.MinX, info.Extent.MinY));
                            var max = map.WorldToImage(new Coordinate(info.Extent.MaxX, info.Extent.MaxY));

                            min = new PointF((float) Math.Round(min.X), (float) Math.Round(min.Y));
                            max = new PointF((float) Math.Round(max.X), (float) Math.Round(max.Y));

                            try
                            {
                                g.DrawImage(bitmap,
                                    (int) min.X, (int) max.Y, (int) (max.X - min.X),
                                    (int) (min.Y - max.Y), 0, 0, tileWidth, tileHeight,
                                    GraphicsUnitType.Pixel, ia);
                            }
                            catch (Exception ee)
                            {
                                Logger.Error(ee.Message);
                            }

                        }
                    }

                    //Add rendered tiles to cache
                    foreach (var kvp in toRender)
                    {
                        if (takenFromCache.ContainsKey(kvp.Key) && !takenFromCache[kvp.Key])
                        {
                            _bitmaps.Add(kvp.Key, kvp.Value);
                        }
                    }

                    graphics.Transform = new Matrix();
                    graphics.DrawImageUnscaled(bmp, 0, 0);
//.........这里部分代码省略.........
开发者ID:lishxi,项目名称:_SharpMap,代码行数:101,代码来源:TileLayer.cs

示例8: Draw

        /// <summary>
        /// Do all rendering associated with this <see cref="CurveItem"/> to the specified
        /// <see cref="Graphics"/> device.  This method is normally only
        /// called by the Draw method of the parent <see cref="CurveList"/>
        /// collection object.
        /// </summary>
        /// <param name="g">
        /// A graphic device object to be drawn into.  This is normally e.Graphics from the
        /// PaintEventArgs argument to the Paint() method.
        /// </param>
        /// <param name="pane">
        /// A reference to the <see cref="GraphPane"/> object that is the parent or
        /// owner of this object.
        /// </param>
        /// <param name="pos">The ordinal position of the current <see cref="Bar"/>
        /// curve.</param>
        /// <param name="scaleFactor">
        /// The scaling factor to be used for rendering objects.  This is calculated and
        /// passed down by the parent <see cref="GraphPane"/> object using the
        /// <see cref="PaneBase.CalcScaleFactor"/> method, and is used to proportionally adjust
        /// font sizes, etc. according to the actual size of the graph.
        /// </param>
        public override void Draw(IGraphics g, GraphPane pane, int pos, float scaleFactor)
        {
            RectangleF rect = GetDrawingRect(pane);

            g.FillEllipse(MakeBrush(), rect);
            g.DrawEllipse(MakePen(), rect);

            if(Image != null)
            {
                var left = rect.Left + rect.Width / 2.0 - Image.Width / 2.0;
                var top = rect.Top + rect.Height / 2.0 - Image.Height / 2.0;
                var tmpRect = new RectangleF((float)left, (float)top, Image.Width, Image.Height);
                Region clip = g.Clip;
                g.SetClip(tmpRect);
                g.DrawImageUnscaled(Image, Rectangle.Round(tmpRect));
                g.SetClip(clip, CombineMode.Replace);

            }
        }
开发者ID:konrad-zielinski,项目名称:ZedGraph,代码行数:41,代码来源:BubbleItem.cs

示例9: PaintOverview

        public static void PaintOverview(IGraphics g, SizeI2 totalSize, RectangleI2 visibleWin,
			Func<int, int, Bitmap2> getOverviewBitmap, float zoomFactorX, float zoomFactorY)
        {
            Size2 overview = CalcOverviewSize(visibleWin.Width, visibleWin.Height, totalSize.Width, totalSize.Height);
            Rectangle2 win = CalcWin(overview, totalSize, visibleWin, zoomFactorX, zoomFactorY);
            g.FillRectangle(Brushes2.White, 0, visibleWin.Height - overview.Height, overview.Width, overview.Height);
            g.DrawImageUnscaled(getOverviewBitmap((int) overview.Width, (int) overview.Height), 0,
                visibleWin.Height - overview.Height);
            Brush2 b = new Brush2(Color2.FromArgb(30, 0, 0, 255));
            if (win.X > 0){
                g.FillRectangle(b, 0, visibleWin.Height - overview.Height, win.X, overview.Height);
            }
            if (overview.Width - win.X - win.Width > 0){
                g.FillRectangle(b, win.X + win.Width, visibleWin.Height - overview.Height, overview.Width - win.X - win.Width,
                    overview.Height);
            }
            if (win.Y > 0){
                g.FillRectangle(b, win.X, visibleWin.Height - overview.Height, win.Width, win.Y);
            }
            if (overview.Height - win.Y - win.Height > 0){
                g.FillRectangle(b, win.X, visibleWin.Height - overview.Height + win.Y + win.Height - 1, win.Width,
                    overview.Height - win.Y - win.Height);
            }
            g.DrawRectangle(Pens2.Black, 0, visibleWin.Height - overview.Height - 1, overview.Width, overview.Height);
            g.DrawRectangle(Pens2.Blue, win.X, visibleWin.Height - overview.Height - 1 + win.Y, win.Width, win.Height);
        }
开发者ID:JurgenCox,项目名称:compbio-base,代码行数:26,代码来源:GraphUtil.cs

示例10: Draw

        /// <summary>
        /// Render this object to the specified <see cref="Graphics"/> device
        /// This method is normally only called by the Draw method
        /// of the parent <see cref="GraphObjList"/> collection object.
        /// </summary>
        /// <param name="g">
        /// A graphic device object to be drawn into.  This is normally e.Graphics from the
        /// PaintEventArgs argument to the Paint() method.
        /// </param>
        /// <param name="pane">
        /// A reference to the <see cref="PaneBase"/> object that is the parent or
        /// owner of this object.
        /// </param>
        /// <param name="scaleFactor">
        /// The scaling factor to be used for rendering objects.  This is calculated and
        /// passed down by the parent <see cref="GraphPane"/> object using the
        /// <see cref="PaneBase.CalcScaleFactor"/> method, and is used to proportionally adjust
        /// font sizes, etc. according to the actual size of the graph.
        /// </param>
        public override void Draw( IGraphics g, PaneBase pane, float scaleFactor )
        {
            if ( _image != null )
            {
                // Convert the rectangle coordinates from the user coordinate system
                // to the screen coordinate system
                RectangleF tmpRect = _location.TransformRect( pane );

                if ( _isScaled )
                    g.DrawImage( _image, tmpRect );
                else
                {
                    Region clip = g.Clip;
                    g.SetClip( tmpRect );
                    g.DrawImageUnscaled( _image, Rectangle.Round( tmpRect ) );
                    g.SetClip( clip, CombineMode.Replace );
                    //g.DrawImageUnscaledAndClipped( image, Rectangle.Round( tmpRect ) );
                }
            }
        }
开发者ID:konrad-zielinski,项目名称:ZedGraph,代码行数:39,代码来源:ImageObj.cs


注:本文中的IGraphics.DrawImageUnscaled方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。