久久久久久久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)用程序并單擊菜單條)
主站蜘蛛池模板: 国产日韩免费观看 | 亚洲精品一 | 亚洲精品9999 | 天天操狠狠操 | 亚洲在线观看视频 | 久久爱综合 | 免费簧片视频 | 欧美在线亚洲 | 久久久久9999亚洲精品 | 国产在线精品一区二区三区 | 天堂一区二区三区四区 | 精品久久久久久久 | 国精久久 | 欧美精品一区二区三区四区 | 91中文字幕在线 | 人人爱干| 欧美一级艳情片免费观看 | 国产视频中文字幕 | 日韩免费视频 | 久久国产成人 | 亚洲精品日韩视频 | 亚洲三区在线观看 | 精品一二三 | 99久久婷婷国产综合精品首页 | 欧美日韩精品久久久免费观看 | 国产精品视频久久久 | 欧美一级久久 | 精品亚洲一区二区三区 | 日操操 | 国产精品视频一二三 | 九九精品在线 | 亚洲日韩中文字幕一区 | 午夜精品一区二区三区在线观看 | 欧美国产中文 | 国产成人久久精品 | 午夜爽爽男女免费观看hd | 婷婷在线视频 | 欧美精品久久久 | 99精品免费久久久久久日本 | 亚洲情侣视频 | 狠狠躁天天躁夜夜躁婷婷老牛影视 |