在Silverlight中打开并保存双色调tiff [英] Opening and saving bitonal tiff in Silverlight

查看:111
本文介绍了在Silverlight中打开并保存双色调tiff的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们公司有一个应用程序,可通过传真或扫描仪接收双色TIFF图像并将其保存到数据库中;当前,我们使用ActiveX控件显示数据库中的图像,但是现在我们想使用Silverlight控件来显示这些图像.但是,我们无法将图像显示或保存为TIFF图像.在ashx处理程序中使用以下代码,我们得到一个空白图像:

Our company has an application that receives bitonal TIFF images via fax or scanner and saves them to a database; currently, we display the images from the database using an ActiveX control, but now we want to use a Silverlight control to display those images instead. However, we are not able to display or save the images as bitonal TIFF images; using the following code in our ashx handler, we get a blank image:

pageno = Convert.ToInt32(context.Request.QueryString("page"))
   'Get image data from database
   Dim bmp() As Byte = ShowDocumentImage(documentID)
   'Get current page of TIFF image as bitmap
   Dim newBmp As Bitmap = GetTifPage(bmp, pageno)
   Dim info As Imaging.ImageCodecInfo = Nothing
   Dim ice As Imaging.ImageCodecInfo
   For Each ice In Imaging.ImageCodecInfo.GetImageEncoders()
       If ice.MimeType = "image/tiff" Then
          info = ice
       End If
   Next
   Dim enc As Imaging.Encoder = Imaging.Encoder.SaveFlag
   Dim ep As New Imaging.EncoderParameters(2)
   ep.Param(0) = New Imaging.EncoderParameter(enc, CLng(Imaging.EncoderValue.MultiFrame))
   ep.Param(1) = New Imaging.EncoderParameter(enc, CLng(Imaging.EncoderValue.CompressionCCITT4))
   If newBmp IsNot Nothing Then
       newBmp.Save(context.Response.OutputStream, info, ep)
       newBmp.Dispose()
   End If


取而代之的是,我们必须将它们另存为JPEG,这确实会向用户显示,但同时也增加了位的深度和文件的大小.这也增加了保存图像所需的时间.将1728x2079 JPEG转换为字节数组大约需要6秒钟,以便可以将其上载到数据库.

有没有办法将图像显示和保存为二进制TIFF,和/或有更快的方法将图像转换为字节数组?


Instead, we have to save them as JPEG, which does display to the user but which also increases the bit depth and the size of the files; it also increases the time it takes to save the image. It takes about 6 seconds to convert a 1728x2079 JPEG to a byte array so that it can be uploaded to the database.

Is there a way to display and save the image as a bitonal TIFF, and/or a faster way to convert the image to a byte array?

推荐答案

我的第一个选择正在尝试转换为PNG,然后保存到数据库.

我将在以后改进此解决方案.让我试试这个.
My first option is trying to convert to a PNG and then saves to DataBase.

I''ll improve this solution later. Let me try this one.


这篇关于在Silverlight中打开并保存双色调tiff的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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