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

如何從具有負(fù)步幅的位圖中復(fù)制像素?cái)?shù)據(jù)?

How can I copy the pixel data from a Bitmap with negative stride?(如何從具有負(fù)步幅的位圖中復(fù)制像素?cái)?shù)據(jù)?)
本文介紹了如何從具有負(fù)步幅的位圖中復(fù)制像素?cái)?shù)據(jù)?的處理方法,對(duì)大家解決問(wèn)題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!

問(wèn)題描述

我一直在尋找將位圖轉(zhuǎn)換為 8bpp 的最快方法.我找到了兩種方法:

I was looking for the fastest way to convert a Bitmap to 8bpp. I found 2 ways:

1.

        public static System.Drawing.Image ConvertTo8bpp(Bitmap oldbmp)
    {
        using (var ms = new MemoryStream())
        {
            oldbmp.Save(ms, ImageFormat.Gif);
            ms.Position = 0;
            return System.Drawing.Image.FromStream(ms);
        }
    }

2. http://www.wischik.com/lu/programmer/1bpp.html

但是:1. 結(jié)果質(zhì)量非常低(托盤(pán)不良)

But: 1. Results in a very low quality result (bad pallet)

2 給了我一個(gè)負(fù)步幅的位圖,當(dāng)我嘗試鎖定位并將數(shù)據(jù)復(fù)制到字節(jié)數(shù)組時(shí),我得到一個(gè)異常:嘗試讀取或?qū)懭胧鼙Wo(hù)的內(nèi)存.這通常表明其他內(nèi)存已損壞.

and 2 gives me a Bitmap with negative stride, when I try to lockbits and copy the data to a byte array I get an exception: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.

        BitmapData bmpData = bmp.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height), ImageLockMode.ReadWrite, bmp.PixelFormat);

        this.stride = bmpData.Stride;
        this.bytesPerPixel = GetBytesPerPixel(bmp.PixelFormat);
        int length = bmpData.Stride * bmp.Height;
        if (this.stride < 0)
            this.data = new byte[-length];
        else
            this.data = new byte[length];
        Marshal.Copy(bmpData.Scan0, data, 0, length);

        //Unlock the bitmap
        bmp.UnlockBits(bmpData);

我怎樣才能讓 2 取得積極的進(jìn)展?或者如何使用負(fù)步幅的鎖位復(fù)制數(shù)據(jù)?

How can I make 2 gives a positive stride? Or how can I copy data using lockbits of a negative stride??

推薦答案

一次復(fù)制 1 行,計(jì)算一行的起始指針為 ((byte*)scan0 + (y * stride)).無(wú)論是正步幅還是負(fù)步幅,代碼都是相同的.

Copy 1 row at a time, calculating the starting pointer for a row as ((byte*)scan0 + (y * stride)). The code will be identical for either positive or negative stride.

這篇關(guān)于如何從具有負(fù)步幅的位圖中復(fù)制像素?cái)?shù)據(jù)?的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

【網(wǎng)站聲明】本站部分內(nèi)容來(lái)源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問(wèn)題,如果有圖片或者內(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 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)用程序并單擊菜單條)
Removing thin border around the menuitems(刪除菜單項(xiàng)周?chē)募?xì)邊框)
主站蜘蛛池模板: 精品成人一区二区 | 日韩一区二区三区在线观看 | 久久精品欧美一区二区三区不卡 | 在线观看成人小视频 | 成年人在线观看 | 国产一区二区在线视频 | 91精品久久久久久久久久 | 日韩成人在线电影 | 毛片在线免费播放 | 少妇一级淫片免费播放 | 亚洲欧美中文日韩在线v日本 | 欧美国产日本一区 | 亚洲a视频 | 亚洲一区免费在线 | 一a级片| 麻豆久久久久久久久久 | 久久久国产精品 | a在线免费观看视频 | 一区二区三区视频在线免费观看 | 精品国产一区二区国模嫣然 | 亚洲午夜av久久乱码 | 精品一区二区免费视频 | 国产ts人妖另类 | 啪啪精品| 色偷偷噜噜噜亚洲男人 | 欧美一区二区三区在线观看 | 国产成人免费一区二区60岁 | 91精品国产乱码久久久 | 91精品国产欧美一区二区成人 | 久久只有精品 | 日韩在线欧美 | 一区二区亚洲 | 欧美一二区 | 国产精品亚洲成在人线 | www日| 久一精品| 亚洲精品黄色 | 日韩精品一区二区三区在线播放 | 国产精品7777777 | av手机免费在线观看 | 日韩1区|