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


C# Bitmap.StretchImage方法代码示例

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


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

示例1: RenderRectangle

        protected internal override void RenderRectangle(Bitmap bmp, Pen pen, int x, int y, int width, int height)
        {
            if (Stretch == Stretch.None)
            {
                bmp.DrawImage(x, y, BitmapSource, 0, 0, BitmapSource.Width, BitmapSource.Height, Opacity);
            }
            else if (width == BitmapSource.Width && height == BitmapSource.Height)
            {
                bmp.DrawImage(x, y, BitmapSource, 0, 0, width, height, Opacity);
            }
            else
            {
                bmp.StretchImage(x, y, BitmapSource, width, height, Opacity);
            }

            if (pen != null && pen.Thickness > 0)
            {
                bmp.DrawRectangle(pen.Color, pen.Thickness, x, y, width, height, 0, 0,
                                      (Color)0, 0, 0, (Color)0, 0, 0, 0);
            }
        }
开发者ID:koson,项目名称:.NETMF_for_LPC17xx,代码行数:21,代码来源:ImageBrush.cs

示例2: BitmapStressTest_RotateImage

        public MFTestResults BitmapStressTest_RotateImage()
        {
            MFTestResults result = MFTestResults.Fail;
            
            Log.Comment("Rotate bitmaps");
            
            Bitmap bmpSrc = null;
            Bitmap bmpDst = null;
            
            try
            {
                bmpDst = new Bitmap(width, height);

                bmpSrc = new Bitmap(WaterFallJpg.WaterFall, Bitmap.BitmapImageType.Jpeg);
                bmpDst.StretchImage(0, 0, bmpSrc, bmpSrc.Width, bmpSrc.Height, 0x0100);
                bmpDst.Flush();

                System.Threading.Thread.Sleep(200);

                
                for (int i = 1; i < 4; ++i )
                {
                    bmpDst.RotateImage(90 * i , 0, 0, bmpSrc, 0, 0, bmpSrc.Width, bmpSrc.Height, 0xFFFF);
                    bmpDst.Flush();

                    System.Threading.Thread.Sleep(200);
                }

                result = MFTestResults.Pass;
            }
            catch (Exception e)
            {
                Log.Exception( "Caught exception: " + e.Message);
            }
            finally
            {
                if(bmpSrc != null)
                {
                    bmpSrc.Dispose();
                }
                if(bmpDst != null)
                {
                    bmpDst.Dispose();
                }
                Debug.GC(true);
                System.Threading.Thread.Sleep(500);
            }

            return result;
        }
开发者ID:aura1213,项目名称:netmf-interpreter,代码行数:50,代码来源:BitmapTest.cs

示例3: StretchImage

        public MFTestResults StretchImage()
        {
            Bitmap screen = new Bitmap(width, height);

            Bitmap btn = new Bitmap(WaterFallJpg.WaterFall, Bitmap.BitmapImageType.Jpeg);
            
            screen.StretchImage(10, 10, 15, 75,
                                    btn,
                                    btn.Width / 2, 0, btn.Width / 2, btn.Height / 2,
                                    256);

            screen.Flush();

            screen.StretchImage(20, 20, 30, 150,
                                    btn,
                                    btn.Width / 2, 0, btn.Width / 2, btn.Height / 2,
                                    256);
            screen.Flush();

            screen.StretchImage(40, 40, 60, 250,
                                    btn,
                                    btn.Width / 2, 0, btn.Width / 2, btn.Height / 2,
                                    256);
            screen.Flush();

            System.Threading.Thread.Sleep(500);

            screen.Dispose();
            btn.Dispose();

            return MFTestResults.Pass;
        }
开发者ID:aura1213,项目名称:netmf-interpreter,代码行数:32,代码来源:BitmapTest.cs

示例4: Scale9ImageManaged

        private static void Scale9ImageManaged(Bitmap bmpDest, int xDst, int yDst, int widthDst, int heightDst, Bitmap bitmap, int leftBorder, int topBorder, int rightBorder, int bottomBorder, ushort opacity)
        {
            if (widthDst < leftBorder || heightDst < topBorder)
                return;
            int widthSrc = bitmap.Width;
            int heightSrc = bitmap.Height;
            int centerWidthSrc = widthSrc - (leftBorder + rightBorder);
            int centerHeightSrc = heightSrc - (topBorder + bottomBorder);
            int centerWidthDst = widthDst - (leftBorder + rightBorder);
            int centerHeightDst = heightDst - (topBorder + bottomBorder);

            //top-left
            //if(widthDst >= leftBorder && heightDst >= topBorder)
            bmpDest.StretchImage(xDst, yDst, leftBorder, topBorder, bitmap, 0, 0, leftBorder, topBorder, opacity);

            //top-right
            if (widthDst > leftBorder /*&& heightDst >= topBorder*/)
                bmpDest.StretchImage(xDst + widthDst - rightBorder, yDst, rightBorder, topBorder, bitmap,
                                     widthSrc - rightBorder, 0, rightBorder, topBorder, opacity);
            //bottom-left
            if (/*widthDst >= leftBorder && */heightDst > topBorder)
                bmpDest.StretchImage(xDst, yDst + heightDst - bottomBorder, leftBorder, bottomBorder, bitmap,
                                     0, heightSrc - bottomBorder, leftBorder, bottomBorder, opacity);
            //bottom-right
            if (widthDst > leftBorder && heightDst > topBorder)
                bmpDest.StretchImage(xDst + widthDst - rightBorder, yDst + heightDst - bottomBorder, rightBorder, bottomBorder, bitmap,
                                     widthSrc - rightBorder, heightSrc - bottomBorder, rightBorder, bottomBorder, opacity);

            //left
            if (/*widthDst >= leftBorder &&*/ centerHeightDst > 0)
                bmpDest.StretchImage(xDst, yDst + topBorder, leftBorder, centerHeightDst, bitmap,
                                     0, topBorder, leftBorder, centerHeightSrc, opacity);

            //top
            if (centerWidthDst > 0 /*&& heightDst >= topBorder*/)
                bmpDest.StretchImage(xDst + leftBorder, yDst, centerWidthDst, topBorder, bitmap,
                                     leftBorder, 0, centerWidthSrc, topBorder, opacity);

            //right
            if (widthDst > leftBorder && centerHeightDst > 0)
                bmpDest.StretchImage(xDst + widthDst - rightBorder, yDst + topBorder, rightBorder, centerHeightDst, bitmap,
                                     widthSrc - rightBorder, topBorder, rightBorder, centerHeightSrc, opacity);

            //bottom
            if (centerWidthDst > 0 && heightDst > topBorder)
                bmpDest.StretchImage(xDst + leftBorder, yDst + heightDst - bottomBorder, centerWidthDst, bottomBorder, bitmap,
                                     leftBorder, heightSrc - bottomBorder, centerWidthSrc, bottomBorder, opacity);

            //center
            if (centerWidthDst > 0 && centerHeightDst > 0)
                bmpDest.StretchImage(xDst + leftBorder, yDst + topBorder, centerWidthDst, centerHeightDst, bitmap,
                                     leftBorder, topBorder, centerWidthSrc, centerHeightSrc, opacity);

        }
开发者ID:aura1213,项目名称:netmf-interpreter,代码行数:54,代码来源:BitmapTest.cs


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