Loading...

sometimes i have error code 22

Support for GdPicture Light Imaging Toolkit and GdPicture Pro Imaging ActiveX/SDK.

sometimes i have error code 22

Postby mabdullah » Mon Jan 31, 2011 7:36 am

i am trying to open TIF multiple file and append it to an existing gdviewer images, but i don't know
what's the wrong with this code it's work sometimes and sometimes it's doesn't work and give me error code 22 at that line of code
Code: Select all
Call Imaging1.TiffAppendPageFromGdPictureImage(GdViewer1.GetNativeImage(), imageID)


Code: Select all
Private Sub OpenTiffFileAndAppendToGdViewer()
    Dim i As Integer
    Dim tifCount As Integer
    Dim imageID As Long
   
    cmddlg.FileName = ""
    cmddlg.Filter = "*.*"
    cmddlg.ShowOpen
    If cmddlg.FileName <> "" Then
        imageID = Imaging2.TiffCreateMultiPageFromFile(cmddlg.FileName)
        tifCount = Imaging2.TiffGetPageCount(imageID)
        For i = 1 To tifCount
            Call Imaging2.TiffSelectPage(imageID, i)
            Call Imaging1.TiffAppendPageFromGdPictureImage(GdViewer1.GetNativeImage(), imageID) ' sometimes it gives error code 22 here
            Imaging2.ReleaseGdPictureImageDC (imageID)
        Next
        Imaging2.CloseNativeImage
        Imaging2.CloseImage (imageID)
        ShowBitmap
        ShowBitmapProperties
    End If
End Sub
mabdullah
 
Posts: 18
Joined: Sun Jan 16, 2011 11:44 am

Re: sometimes i have error code 22

Postby mabdullah » Mon Jan 31, 2011 8:16 am

The problem was not in the code above and the code above is working good without error sorry for confusing you
but i found the problem when i am trying to save gdviewer images to multiple tif file with CompressionCCITT4 because some images in the gdviewer are colored images as i think
so the problem here in that line
Code: Select all
Call Imaging1.TiffSaveAsNativeMultiPage(cmddlg.FileName, CompressionCCITT4)

and when i change that line to
Code: Select all
Call Imaging1.TiffSaveAsNativeMultiPage(cmddlg.FileName, CompressionNone)

it's work and has no error but the problem is the file size is too large, so can you help me to reduce the size without giving me errors

the whole code of saving
Code: Select all
Private Sub SaveAsTiff()
    Dim nPage As Integer
    cmddlg.FileName = ""
    cmddlg.Filter = "*.TIF"
    cmddlg.ShowSave
    If cmddlg.FileName <> "" Then
        If Imaging1.GetStat = 0 Then
            GdViewer1.LockControl = True
            For nPage = 1 To GdViewer1.PageCount
                GdViewer1.DisplayFrame (nPage)
                If nPage = 1 Then
                    Imaging1.SetNativeImage (Imaging1.CreateClonedImage(GdViewer1.GetNativeImage))
                    Call Imaging1.TiffSaveAsNativeMultiPage(cmddlg.FileName, CompressionNone)
                    'Call Imaging1.TiffSaveAsNativeMultiPage(cmddlg.FileName, CompressionCCITT4)
                Else
                    Call Imaging1.TiffAddToNativeMultiPage(GdViewer1.GetNativeImage)
                End If
            Next nPage
            GdViewer1.LockControl = False
            Imaging1.TiffCloseNativeMultiPage
        End If
   End If
End Sub
mabdullah
 
Posts: 18
Joined: Sun Jan 16, 2011 11:44 am

Re: sometimes i have error code 22

Postby Loïc » Mon Jan 31, 2011 4:12 pm

Hi,

Just convert the image to 1 bit-depth format using the ConvertTo1Bpp method before saving.
Let me know if you need more precisions.

Kind regards,

Loïc
Loïc Carrère, support team.
www.orpalis.com
User avatar
Loïc
Site Admin
 
Posts: 4437
Joined: Tue Oct 17, 2006 10:48 pm
Location: France


Return to GdPicture [Pro] ActiveX

Who is online

Users browsing this forum: No registered users and 3 guests

cron