久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

C# 創(chuàng)建位圖時(shí)內(nèi)存不足

C# Out of Memory when Creating Bitmap(C# 創(chuàng)建位圖時(shí)內(nèi)存不足)
本文介紹了C# 創(chuàng)建位圖時(shí)內(nèi)存不足的處理方法,對(duì)大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!

問題描述

我正在創(chuàng)建一個(gè)應(yīng)用程序(Windows 窗體),允許用戶根據(jù)他們選擇的位置(拖動(dòng)以選擇區(qū)域)截取屏幕截圖.我想添加一個(gè)放大的小預(yù)覽窗格",以便用戶可以更精確地選擇他們想要的區(qū)域(更大的像素).在 mousemove 事件中,我有以下代碼...

I'm creating an application (Windows Form) that allows the user to take a screenshot based on the locations they choose (drag to select area). I wanted to add a little "preview pane" thats zoomed in so the user can select the area they want more precisely (larger pixels). On a mousemove event i have a the following code...

private void falseDesktop_MouseMove(object sender, MouseEventArgs e)
    {
        zoomBox.Image = showZoomBox(e.Location);
        zoomBox.Invalidate();
        bmpCrop.Dispose();
    }

private Image showZoomBox(Point curLocation)
    {
        Point start = new Point(curLocation.X - 50, curLocation.Y - 50);
        Size size = new Size(100, 90);
        Rectangle rect = new Rectangle(start, size);
        Image selection = cropImage(falseDesktop.Image, rect);
        return selection;
    }

private static Bitmap bmpCrop;
private static Image cropImage(Image img, Rectangle cropArea)
    {
        if (cropArea.Width != 0 && cropArea.Height != 0)
        {
            Bitmap bmpImage = new Bitmap(img);
            bmpCrop = bmpImage.Clone(cropArea, bmpImage.PixelFormat);
            bmpImage.Dispose();
            return (Image)(bmpCrop);
        }
        return null;
    }

失敗并出現(xiàn)內(nèi)存不足異常的行是:

The line that fails and has the Out of Memory exception is:

bmpCrop = bmpImage.Clone(cropArea, bmpImage.PixelFormat);

基本上它的作用是在鼠標(biāo)指針周圍取一個(gè) 100x90 的矩形并將其拉入縮放框,這是一個(gè)圖片框控件.但是,在此過程中,我收到內(nèi)存不足錯(cuò)誤.我在這里做錯(cuò)了什么?

Basically what this does is it takes a 100x90 rectangle around the mouse pointer and pulls that into the zoomBox, which is a picturebox control. However, in the process, i get an Out Of Memory error. What is it that i am doing incorrectly here?

感謝您的幫助.

推薦答案

C# 成像中的內(nèi)存不足,通常是錯(cuò)誤的 rect 或 point 的標(biāo)志 - 有點(diǎn)紅鯡魚.我敢打賭 start 在發(fā)生錯(cuò)誤或 Size.Hight + Y 或 Size.Width + X 大于圖像的高度或?qū)挾葧r(shí)具有 負(fù) X 或 Y.

Out of memory in C# imaging, is usually sign of wrong rect or point - a bit of red herring. I bet start has negative X or Y when error happens or the Size.Hight + Y or Size.Width + X is bigger than Hight or width of the image.

這篇關(guān)于C# 創(chuàng)建位圖時(shí)內(nèi)存不足的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

【網(wǎng)站聲明】本站部分內(nèi)容來(lái)源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請(qǐng)聯(lián)系我們刪除處理,感謝您的支持!

相關(guān)文檔推薦

Right-click on a Listbox in a Silverlight 4 app(右鍵單擊 Silverlight 4 應(yīng)用程序中的列表框)
WPF c# webbrowser scrolls over top menu(WPF c# webbrowser 在頂部菜單上滾動(dòng))
C# Console app - How do I make an interactive menu?(C# 控制臺(tái)應(yīng)用程序 - 如何制作交互式菜單?)
How to add an icon to System.Windows.Forms.MenuItem?(如何向 System.Windows.Forms.MenuItem 添加圖標(biāo)?)
How to avoid duplicate form creation in .NET Windows Forms?(如何避免在 .NET Windows Forms 中創(chuàng)建重復(fù)的表單?)
UI Automation Control Desktop Application and Click on Menu Strip(UI自動(dòng)化控制桌面應(yīng)用程序并單擊菜單條)
主站蜘蛛池模板: 女人夜夜春| 91久久综合亚洲鲁鲁五月天 | 色爱综合网 | 亚洲欧美日韩电影 | 成人亚洲综合 | 精品国产乱码久久久久久丨区2区 | 免费成人高清在线视频 | 人人人干 | 亚洲精品黑人 | 久久久久久精 | 天天人人精品 | 欧美一二三区 | 久久国产精品免费视频 | 亚洲精品成人av久久 | 日本aa毛片a级毛片免费观看 | 一级a性色生活片久久毛片 一级特黄a大片 | a级片网站 | 黄片毛片免费看 | 国产精品视频不卡 | 91久久久精品国产一区二区蜜臀 | 97久久精品午夜一区二区 | 国产aⅴ精品 | 亚洲在线一区 | 北条麻妃99精品青青久久主播 | 久久男人| 观看av | 在线观看视频91 | 国产日韩欧美一区 | 日韩午夜精品 | 在线观看亚洲专区 | 久久久精品一区二区三区四季av | 黄色免费网站在线看 | 国产精品一区久久久 | 999国产视频 | 成人精品一区 | 欧美视频三区 | 日韩精品在线观看免费 | caoporon| 久久免费视频观看 | 成人h视频在线 | 日韩一区二区三区四区五区 |