找回密码
 立即注册

QQ登录

只需一步,快速开始

mosquito
初级会员   /  发表于:2016-4-6 14:59:15
16#
那就是说我在save图片的时候最后这个位深参数应该用e.Image.BitsPerPixel的值,而不应该自己随意指定对吗
回复 使用道具 举报
AvoCaDolol活字格认证 Wyn认证
社区贡献组   /  发表于:2016-4-6 14:44:34
15#
mosquito 发表于 2016-4-6 13:58
还有个问题想咨询下,一般扫描仪扫描的图像是多少像素的呀,我在_codecs.Save(e.Image, fileName, RasterIm ...

扫描图像的分辨率在扫描仪的设置里。
保存无法更改,因为图像分辨率属于图像本身的属性。
最后一个参数是BitsPerPixel,每像素bit率,俗称位深,一般彩色图片为24bit,黑白图片为2bit。
如果需要修改分辨率,可以在扫描之前修改扫描仪属性。

扫描仪扫描图像的像素数算法是:长X宽X位深,这个是总像素数。
回复 使用道具 举报
mosquito
初级会员   /  发表于:2016-4-6 13:58:17
14#
还有个问题想咨询下,一般扫描仪扫描的图像是多少像素的呀,我在_codecs.Save(e.Image, fileName, RasterImageFormat.Tif, 1);的时候最后一个参数是保存的分辨率吧,这个值我设置多少合适呢?麻烦您指导下
回复 使用道具 举报
mosquito
初级会员   /  发表于:2016-4-6 13:44:51
13#
我试下,万分感谢
回复 使用道具 举报
AvoCaDolol活字格认证 Wyn认证
社区贡献组   /  发表于:2016-4-6 13:30:34
12#
AvoCaDolol 发表于 2016-4-1 15:28
Hello,
更改大小有个SizeCommand ,例子代码:
// Load the source image from disk

有一个最简单的办法做到拼接,对吧,你的意思是拼接。
我下面的代码是两张一摸一样的图片,图片1、2,大小一致,然后横向拼接到一起。
思路是:
1、获取图片1的大小信息
2、创建一个空白RasterImage,这个对象的尺寸是图片1宽度的两倍。
3、在这个空白图片的左侧加载图片1,右侧加载图片2
4、保存这个空白图片对象,就会得到拼接到一起的图片3.
示例代码:
CodecsImageInfo info = codecs.GetInformation(strFile1, true);
            RasterImage img = new RasterImage(RasterMemoryFlags.Conventional, info.Width * 2, info.Height, info.BitsPerPixel, info.Order, info.ViewPerspective, null, IntPtr.Zero, 0);
            RasterImage image1 = codecs.Load(strFile1);
            RasterImage image2 = codecs.Load(strFile2);

            CombineCommand command = new CombineCommand();
            command.SourceImage = image1;
            // the rectangle that represents the affected area of the destination image.
            command.DestinationRectangle = new LeadRect(0, 0, image1.Width, image1.Height);
            // The source point, which represents the source point of the source image which is to be combined.
            command.SourcePoint = new LeadPoint(0, 0);
            // the operations that will be performed to produce the result, and the channel that will be used to achieve this result.
            command.Flags = CombineCommandFlags.OperationAdd ;
            command.Run(img);

            command.SourceImage = image2;
            // the rectangle that represents the affected area of the destination image.
            command.DestinationRectangle = new LeadRect(image1.Width, 0, image1.Width, image1.Height);
            // The source point, which represents the source point of the source image which is to be combined.
            command.SourcePoint = new LeadPoint(0, 0);
            // the operations that will be performed to produce the result, and the channel that will be used to achieve this result.
            command.Flags = CombineCommandFlags.OperationAdd;
            command.Run(img);
            this.pictureBox3.Image = RasterImageConverter.ChangeToImage(img, Leadtools.Drawing.ChangeToImageOptions.ForceChange);
回复 使用道具 举报
mosquito
初级会员   /  发表于:2016-4-6 09:21:42
11#
这个方法确实是改变了图像的大小了,但是图像也跟着拉伸了,我现在是想原图不变但是图像的尺寸的宽度增加一倍,然后在增加的那块尺寸上合并上一个新的图片,上面的方法图像跟着拉伸,我合并的图像还是把原来的图像给覆盖了一部分,没有别的解决方法了吗?
回复 使用道具 举报
AvoCaDolol活字格认证 Wyn认证
社区贡献组   /  发表于:2016-4-1 15:28:50
10#
mosquito 发表于 2016-3-30 16:54
我只找到一个image1.ChangeHeight();没找到改变宽的方法,还是还有别的方法可以把图像尺寸整体放大

Hello,
更改大小有个SizeCommand ,例子代码:
// Load the source image from disk
   RasterImage image = codecs.Load(srcFileName);
   SizeCommand command = new SizeCommand();
   command.Width = 128;
   command.Height = 128;
   command.Flags = RasterSizeFlags.Resample;
   command.Run(image);
具体说明请参考这里:https://www.leadtools.com/help/l ... ng.sizecommand.html
回复 使用道具 举报
mosquito
初级会员   /  发表于:2016-3-30 16:54:26
9#
我只找到一个image1.ChangeHeight();没找到改变宽的方法,还是还有别的方法可以把图像尺寸整体放大
回复 使用道具 举报
mosquito
初级会员   /  发表于:2016-3-30 16:29:02
8#
如何把一个图片的尺寸变大呀,麻烦指导下哈
回复 使用道具 举报
AvoCaDolol活字格认证 Wyn认证
社区贡献组   /  发表于:2016-3-30 16:14:40
7#
mosquito 发表于 2016-3-30 15:08
感觉那个效果是在图片的上面再放一个图片,我想要的是把两个图片按照纵向或者横向拼接成一个图片这个可以实 ...

Combine命令就是干这个的,只是那个示例中是层叠,如果横向拼合的话,需要将某个图片的尺寸变大,然后将第二张图的位置放到第一张图的右侧,然后用这个命令将两张图合并在一起。
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 立即注册
返回顶部