當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。