增加图像的分辨率(dpi) [英] Increase the resolution (dpi) of an image

查看:236
本文介绍了增加图像的分辨率(dpi)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不知道如何可行,这将是没有一些第三方库,但这里有云:结果

I'm not sure how feasible this will be without some thirdparty libraries, but here goes:

我有一个形象,450x900大小,其中即时通讯试图打印。结果
问题是,我使用的打印发送原始数据到打印机的方法。结果
的图像的分辨率是96dpix96dpi,打印机在203DPI运行。结果
所以......拍摄的图像小。

I have an image, 450x900 in size, which im trying to print.
The problem is, the method I'm using to print is sending raw data to the printer.
The resolution of the image is 96dpix96dpi, the printer runs at 203dpi.
So... the image comes out small.

我需要增加图像的DPI在其真实尺寸打印。

I need to increase the dpi of the image to print it at its 'real' size.

Bitmap b0 = LoadBitmap();

//I need to rotate it because for some odd reason it prints backwards and upside down.
b0.RotateFlip(RotateFlipType.Rotate180FlipX);

//Set a new resolution, 203dpi
b0.SetResolution(203, 203);

//I need to save and reload the bitmap, because RotateFlip compresses it.
//(annoying as hell, took me ages to figure out why it wasn't working.)
Stream imgStream = new MemoryStream();
b0.Save(imgStream, ImageFormat.Bmp);
b0 = new Bitmap(imgStream);

//get my byte array
ImageConverter converter = new ImageConverter();
byte[] imageData = (byte[])converter.ConvertTo(b0, typeof(byte[]));

所以,相当直截了当。
但SetResolution(...)并不真正似乎无所不能。
图像打印完全相同的大小,并将所得的字节数组是完全相同的大小。

So, fairly straight forward. But SetResolution(...) doesn't actually seem to do anything. The image prints exactly the same size, and the resultant byte array is exactly the same size.

所以我试图找出它实际上是做什么的。结果
不过,我想这需要垫出所有的额外像素的图像数据做什么,我希望它?

So I'm trying to work out what it is actually doing.
But I guess it would need to pad out all the image data with extra pixels to do what I want it to?

如果这不是一个实用的方法,有没有我可以用它来得到想要的效果?一个简单的拉伸方法或类似的结果。

If this isn't a practical method, is there a simple stretch method or similar I can use to get the desired effect?

推荐答案

为什么不扩大你的形象,以更大:

Why not scale your image to be bigger:

        System.Drawing.Bitmap b0 = LoadBitmap();
        double scale = 203/96;
        int width = (int)(b0.Width * scale);
        int height = (int)(b0.Height * scale);
        System.Drawing.Bitmap bmpScaled = new System.Drawing.Bitmap(b0,width, height);

这篇关于增加图像的分辨率(dpi)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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