如何在不进行任何压缩的情况下保存位图文件

How can I save bitmap file without any compression

我想在不进行任何压缩的情况下保存位图文件(C# 核心)。

有什么办法吗?

即我正在使用 magickImage,并尝试使用 bitdepth = 24(这是 RGB 位数)进行保存,将一个像素与 RGB:

对于红色:hexa 79 (121 dec),绿色:7A hex,蓝色:7B hex。

当我以二进制形式打开它时,即通过:

https://www.onlinehexeditor.com/

我没有看到这些值(79 十六进制、7a 十六进制和 7b 十六进制)。

有什么方法可以用准确的 rgb 值保存该图像吗?

此外,我打算将非常大的图像文件拆分成小部分(可以是 100K x 100K 像素),并通过一种快速简便的方法将它们合并在一起。

我该怎么做?

你可以很容易地将它转换成 C#,但为什么不直接保存它而不去骚扰它呢?

Private Shared Function ConvertImageBasic(filepath As String) As String

    Try

        'Open image
        Dim sourceImg As Bitmap = New Bitmap(filepath)

        'Set new path for the converted image
        filepath = IO.Path.GetTempPath & "image.bmp"

        'Save opened image as a bitmap file type
        sourceImg.Save(filepath, ImageFormat.Bmp)

    Catch ex As Exception

        MsgBox("Failed to convert image, " & ex.Message, vbRetryCancel)

    End Try

    ConvertImageBasic = filepath
End Function

您也可以只用 ImageMagick 保存它。

using (MagickImage image = new MagickImage(filepath))
{
    image.Format = MagickFormat.Bmp;
    image.Write("Snakeware.bmp");
}

至于附加图片,看看这些:

MagickImageCollection.AppendHorizontally()
MagickImageCollection.AppendVertically()