从文件加载位图RGB格式(不带alpha) [英] Load a bitmap from file in RGB format (without alpha)

查看:133
本文介绍了从文件加载位图RGB格式(不带alpha)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只是想加载.bmp文件并获得24位RGB格式的位图对象(或RGB格式32位)。

i simply want to load a .BMP file and get the Bitmap object in 24bit RGB format (or 32bit in RGB format).

所有方法我试过返回与的PixelFormat = Format32bppArgb一个位图/ Image对象。即使当然骨形态发生蛋白所不具备阿尔法。

All methods I tried return a Bitmap/Image object with PixelFormat = Format32bppArgb. Even if of course BMPs don't have alpha.

new Bitmap(System.Drawing.Image.FromFile(fileName, true));
new Bitmap(fileName);

我目前通过在24位RBG的所述第一对象复制到另一个存储器中的位图解决问题。

I currently solve the problem by copying the first object to another in memory bitmap at 24bit RBG.

有没有一种单一的方法做到这一点?

Is there a single method to do it?

感谢

推荐答案

您可以将其克隆到一个RGB格式之一:

You can clone it to a RGB format one:

var bitmapInRgbFormat = loadedBitmap.Clone(new Rectangle(0, 0, loadedBitmap.Width, loadedBitmap.Height), PixelFormat.Format32bppRgb)

这篇关于从文件加载位图RGB格式(不带alpha)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆