Merging images into a very large image

Discussions about image processing and document imaging.
Post Reply
andrew
Posts: 18
Joined: Tue Jul 24, 2007 9:30 pm

Merging images into a very large image

Post by andrew » Tue Jan 17, 2017 8:36 pm

I am try to merge a number of large and long bitonal TIF images (41,600x 2,000) into a single large image (41,600 x 30,000), using something similar to the following code (x64) of course.

Code: Select all

Dim ofd As New OpenFileDialog
        ofd.Multiselect = True
        Dim itop As Integer = 0
        Imaging1.ReleaseGdPictureImage(PrimaryImageID)
        PrimaryImageID = 0
        If ofd.ShowDialog = DialogResult.OK Then
            For Each fn As String In ofd.FileNames
                If PrimaryImageID = 0 Then
                    PrimaryImageID = Imaging1.CreateGdPictureImageFromFile(fn)
                    itop = Imaging1.GetHeight(PrimaryImageID)
                    Imaging1.SetVerticalResolution(PrimaryImageID, 300)
                    Imaging1.SetHorizontalResolution(PrimaryImageID, 300)
                Else
                    Imaging1.ReleaseGdPictureImage(TempImageID)
                    TempImageID = Imaging1.CreateGdPictureImageFromFile(fn)
                    Imaging1.AddBorderBottom(PrimaryImageID, Imaging1.GetHeight(TempImageID), Color.White)
                    If Imaging1.GetStat <> GdPicture12.GdPictureStatus.OK Then MsgBox(Imaging1.GetStat.ToString)
                    If Imaging1.GetWidth(TempImageID) > Imaging1.GetWidth(PrimaryImageID) Then Imaging1.AddBorderRight(PrimaryImageID, Imaging1.GetWidth(TempImageID) - Imaging1.GetWidth(PrimaryImageID), Color.White)
                    If Imaging1.GetStat <> GdPicture12.GdPictureStatus.OK Then MsgBox(Imaging1.GetStat.ToString)
                    Imaging1.DrawGdPictureImage(TempImageID, PrimaryImageID, 0, itop - 1, Imaging1.GetWidth(TempImageID), Imaging1.GetHeight(TempImageID), Drawing2D.InterpolationMode.Low)
                    Imaging1.ConvertTo1BppFast(PrimaryImageID)
                    Imaging1.ReleaseGdPictureImage(TempImageID)
                    itop = Imaging1.GetHeight(PrimaryImageID)
                End If

                If Imaging1.GetStat <> GdPicture12.GdPictureStatus.OK Then MsgBox(Imaging1.GetStat.ToString)
                Viewer1.DisplayFromGdPictureImage(PrimaryImageID)

            Next
            Viewer1.DisplayFromGdPictureImage(PrimaryImageID)
        End If
after adding the 5th strip, the image is no longer displayable in the viewer (total mem usage of over 4GB), after adding the 6th or 7th the image will not save correctly with a "Generic Error". After adding 9 or 10 strips the GdPicture.Imaging status is out of memory (total mem usage of about 5.0GB) .
MemUsage.PNG
MemUsage.PNG (11.53 KiB) Viewed 2668 times
I have a number of the completed large image (41,600 x 30,000) that were produced using another tools kit, and the images open fine, though not in the GDViewer, as we get the same out of memory issue.

My Dev box is running 16GB with 11GB free when starting the application, I have tested the code on production servers with 32/64GB with the same effect.

Any help yo can provide would be greatly appreciated.

- Andrew
Attachments
LargeStripsSample.zip
(1.83 MiB) Downloaded 81 times

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest