第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

在C#中轉(zhuǎn)換位圖PixelFormats

在C#中轉(zhuǎn)換位圖PixelFormats

一只萌萌小番薯 2019-11-02 14:21:59
我需要將位圖從轉(zhuǎn)換PixelFormat.Format32bppRgb為PixelFormat.Format32bppArgb。我希望使用Bitmap.Clone,但似乎無法正常工作。Bitmap orig = new Bitmap("orig.bmp");Bitmap clone = orig.Clone(new Rectangle(0,0,orig.Width,orig.Height), PixelFormat.Format24bppArgb);如果我運(yùn)行上面的代碼,然后檢查clone.PixelFormat,它將設(shè)置為PixelFormat.Format32bppRgb。怎么回事/如何轉(zhuǎn)換格式?
查看完整描述

3 回答

?
慕后森

TA貢獻(xiàn)1802條經(jīng)驗(yàn) 獲得超5個(gè)贊

由于某種原因,如果您Bitmap從文件路徑(即)創(chuàng)建一個(gè)Bitmap bmp = new Bitmap("myimage.jpg");并對(duì)其進(jìn)行調(diào)用Clone(),則返回的內(nèi)容Bitmap將不會(huì)轉(zhuǎn)換。


但是,如果您Bitmap從舊版本創(chuàng)建另一個(gè)版本Bitmap,Clone()則會(huì)按預(yù)期工作。


嘗試這樣的事情:


using (Bitmap oldBmp = new Bitmap("myimage.jpg"))

using (Bitmap newBmp = new Bitmap(oldBmp))

using (Bitmap targetBmp = newBmp.Clone(new Rectangle(0, 0, newBmp.Width, newBmp.Height), PixelFormat.Format32bppArgb))

{

    // targetBmp is now in the desired format.

}


查看完整回答
反對(duì) 回復(fù) 2019-11-02
?
qq_遁去的一_1

TA貢獻(xiàn)1725條經(jīng)驗(yàn) 獲得超8個(gè)贊

using (var bmp = new Bitmap(width, height, PixelFormat.Format24bppArgb))

using (var g = Graphics.FromImage(bmp)) {

  g.DrawImage(..);

}

應(yīng)該那樣工作。也許您想設(shè)置一些參數(shù)g以定義質(zhì)量等的插值模式。


查看完整回答
反對(duì) 回復(fù) 2019-11-02
  • 3 回答
  • 0 關(guān)注
  • 1565 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)