.NETでシンプルな画像ビューアを構築し、ブラウザにマルチフレームTIFF画像を表示する必要があります。現在、マルチフレームTIFFと同じデータベースに混在しているJPEGをストリーミングバックする(ashx)ハンドラー設定があり、このハンドラーはTIFFファイルの最初のフレームも現在の状態で返すことに注意してください。 。以下のVB.NETコード(ハンドラーの一部)では、TIFFファイルに複数のフレームがあるかどうかを識別でき、フレームをつなぎ合わせようとしましたが、まだ成功していません。同様のアプローチを使用してマルチフレームTIFFを返品した人はいますか?注:以下のコードを開発する際の参考として、マルチフレームTIFF画像を開く方法を使用しました。
context.Response.Cache.SetCacheability(HttpCacheability.NoCache)
context.Response.Cache.SetNoStore()
context.Response.Cache.SetExpires(DateTime.MinValue)
imageList = GetPhoto(picid)
If (imageList IsNot Nothing) Then
Dim img As Image
Dim prevImageHeight = 0
For Each img In imageList
Dim imgGraphics As Graphics = Graphics.FromImage(img)
imgGraphics.DrawImage(img, 0, prevImageHeight, img.Width, img.Height * imageList.Count)
prevImageHeight += img.Height
img.Save(context.Response.OutputStream, ImageFormat.Jpeg)
img.Dispose()
Next img
Else
' Return 404
context.Response.StatusCode = 404
context.Response.End()
End If
GetPhoto関数のコードは次のとおりです。
Public Function GetPhoto(ByVal id As String) As List(Of Image)
Dim db As New UtilDb
Dim imageLocation As String
Dim errMsg As String = ""
Dim imageList As New List(Of Image)
Dim returnImage As Bitmap = Nothing
imageLocation = GetFileName(id)
If (imageLocation IsNot Nothing) Then
Dim iFile As Image = Image.FromFile(imageLocation)
If (imageLocation.ToUpper.EndsWith("TIF")) Then
Dim frameCount As Integer = iFile.GetFrameCount(FrameDimension.Page)
Dim i As Integer
If (frameCount > 1) Then
For i = 0 To frameCount - 1
iFile.SelectActiveFrame(FrameDimension.Page, i)
returnImage = New Bitmap(iFile, iFile.Width * 0.4, iFile.Height * 0.4)
imageList.Add(returnImage)
Next i
Else
returnImage = New Bitmap(iFile, iFile.Width * 0.4, iFile.Height * 0.4)
imageList.Add(returnImage)
End If
Else
Dim scaledWidth As Integer = (iFile.Width / iFile.Height) * 480
returnImage = New Bitmap(iFile, scaledWidth, 480)
imageList.Add(returnImage)
End If
iFile.Dispose()
End If
Return imageList
End Function
マルチフレームTIFFの各フレームを連続した画像に配置してブラウザに送り返すことは可能ですか?マルチフレームTIFFをPDFなどの別の形式に変換することに力を注ぐ必要がありますか?私は基本的に変換パッケージを購入するための予算を持っていません...どんな助けやガイダンスも大歓迎です!