为什么Bitmap.Save改变图像的大小? [英] Why Bitmap.Save changes image's size?

查看:1373
本文介绍了为什么Bitmap.Save改变图像的大小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我成功改变形象的 DateTaken 属性。但是,重新保存图像后,它的大小改变。我与 Matlab的检查,两个图像'字节是相同的。

I succeeded to change image's DateTaken property. But, after resaving the image, its size changed. I checked with Matlab and both images' bytes are identical.

要检查是否改变属性更改大小,我决定只打开文件并将其保存在不改变任何属性。在code是如下:

To check whether changing property changes the size I decided just to open the file and save it without changing any properties. The code is below:

using (var image = new Bitmap(@"C:\Temp\1.jpg"))
{  
    image.Save(@"C:\Temp\2.jpg");
}

不过,规模仍然改变。原来的JPEG图像 1.JPG 的大小是 1.88 MB(1975162字节)。它重新保存为 2.JPG ,形象改变的大小 1.86 MB(1960824字节)后
结果

But, the size still changed. The size of the original jpeg image 1.jpg is 1.88 MB (1,975,162 bytes). After resaving it to 2.jpg, the size of the image changes to 1.86 MB (1,960,824 bytes).

这可能是什么问题呢?虽然Matlab的保证我说的图像字节没有改变我想从你听到 Bitmap.Save 不应该改变图像的字节数。

What could be the problem? Though Matlab ensured me that the images' bytes were not changed I want to hear from you that Bitmap.Save shouldn't change the image's bytes.

推荐答案

JPEG能力,即交易融为一体pression冲减忠实于原始变量COM pression的。能影响大小的因素包括:

JPEG is capable of variable compression that trades compression off against fidelity to the original. The factors that can effect size include:


  1. 具体的JPEG格式:顺序或逐行。顺序连接codeS的所有在单一扫描组件的数据。渐进带codeS一个在多次扫描组件。进步往往能产生更大的COM pression。然而,有一种适用于渐进式的设置万千。

  1. The specific JPEG format: Sequential or Progressive. Sequential encodes all the data for a component in a single scan. Progressive encodes a component in multiple scans. Progressive can often produce greater compression. However, there is a myriad of settings that apply to progressive.

采样。 JPEG允许Cb和Cb分量以比Y分量较低的速率被采样。如果采取对每两个Y(垂直和水平)一种Cb和Cr采样,将得到每4 Y样本1 CB和CR样品。从在减少一半的数据量,以玉米preSS 12至6

Sampling. Jpeg allows the Cb and Cb components to be sampled at a lower rate than the Y component. If you take one Cb and Cr sample for every two Ys (vertical and horizontal), you get 1 Cb and CR sample for every 4 Y samples. That reduces the amount of data to compress from in half from 12 to 6.

量化表。量化表选择为JPEG COM pression设置的主要形式。许多卫浴codeRS隐藏在这背后,一个质的设置。

Quantization tables. Quantization table selection is the main form of JPEG compression setting. Many encoders hide this behind a "quality" setting.

霍夫曼表。部分带codeRS使用predefined霍夫曼表。您可以得到更好的融为一体pression如果EN codeR生成霍夫曼表的特定图像(慢,更多的工作)进行了优化。

Huffman tables. Some encoders use predefined Huffman tables. You can get better compression if the encoder generates a Huffman table optimized for the specific image (slower and more work).

除非你RECOM preSS采用在原来相同的设置,你会得到不同的输出大小。即使您使用相同的设置,你平时拿出因四舍五入,不同的值:JPEG使用浮点计算的四舍五入取整数

Unless you recompress using the same settings at the original, you will get a different output size. Even if you use the identical settings, you usually come up with different values because of rounding: JPEG uses floating point calculations that get rounded to integers.

这篇关于为什么Bitmap.Save改变图像的大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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