Support Center

saving a multipage image

Christian Sep 04, 2013 11:20AM EDT

Dear support,

I'm trying to create a multipage image on disk, using "hImage"s from another Imageman control in a loop.
Problem is, when a given page gets some kind of processing (brightness, for example), that page is black in the multipage image.

I'm using VB6 and Imageman 8.80, and here's some code to make thing clearer.
"ImgManDoc" is the control containing the original file.
"ImgManPrint" is the control containing the visible page, that may be changed by the user in some way (brightness, contrast, etc).
"mvAjustes" is an array with a structure containing the modifications the user made to an image.

This code is very similar to that one in Imageman's documentation ("Handling Multi Page Images").


Public Function SalvaDocumento(ByVal sArquivo As String, ByRef OUT_sMsgErro As String) As Boolean

Dim i As Long
Dim bErro As Boolean

On Error GoTo Erro

ImgManPrint.Picture = ""

For i = 0 To ImgManDoc.Pages - 1
ImgManDoc.PageNumber = i
With ImgManPrint
.hImage = ImgManDoc.hImage
If mvAjustes(i).Rotacao != 0 Then .Rotate mvAjustes(i).Rotacao, 0
If mvAjustes(i).Brilho != 0 Then .Brightness mvAjustes(i).Brilho
If mvAjustes(i).Contraste != 0 Then .Contrast mvAjustes(i).Contraste, -1, All
If mvAjustes(i).Gamma != 1 Then .Gamma mvAjustes(i).Gamma
If mvAjustes(i).Deskew != -1 Then .Deskew mvAjustes(i).Deskew
End With
If Not pSalvaImagem(ImgManPrint, sArquivo) Then
bErro = True
Exit For
End If

If Not bErro Then
SalvaDocumento = True
End If

GoTo Sai

OUT_sMsgErro = Error$
GoTo Sai
On Error Resume Next
ImgManPrint.Picture = ""

End Function

Private Function pSalvaImagem(ByVal ctl As ImageControl, ByVal sArquivo As String) As Boolean

Dim sExtensao As String
Dim Attrs As IMActX8Ctl.Attributes

On Error GoTo Erro

Set Attrs = New IMActX8Ctl.Attributes
Attrs.Add "APPEND", "ON", IMActX8Ctl.IMString
Attrs.Add "OVERWRITE", "OFF", IMActX8Ctl.IMString
Attrs.Add "COMPRESS", "True", IMActX8Ctl.IMString

sExtensao = UCase$(Right$(sArquivo, 3))

If sExtensao = "PDF" Then

Attrs.Add "EXTENSION", "PDF", IMActX8Ctl.IMString
If ctl.ImageBitDepth < 24 Then
Attrs.Add "PDF_COMPRESS", "FLATE", IMActX8Ctl.IMString
Attrs.Add "PDF_COMPRESS", "JPEG", IMActX8Ctl.IMString
End If
ctl.SaveAs sArquivo, Attrs

ElseIf sExtensao = "TIF" Then

Attrs.Add "EXTENSION", "TIF", IMActX8Ctl.IMString
If ctl.ImageBitDepth > 7 Then
Attrs.Add "TIFF_COMPRESS", "JPEG_DCT", IMActX8Ctl.IMString
Attrs.Add "LOSSY_QUALITY", 80, IMActX8Ctl.IMString
Attrs.Add "TIFF_COMPRESS", "GROUP4", IMActX8Ctl.IMString
End If
ctl.SaveAs sArquivo, Attrs


ctl.SaveAs sArquivo

End If

pSalvaImagem = True

Exit Function
Resume Fecha

End Function


Suppose I have a 3-page image on the screen. If the user changes page 2 -- adjusting brightness, for example -- and then tries to save the file, "SalvaDocumento" is called. The end result is page 1 is ok, page 2 is black, and page 3 is ok.

Tried a lot of things: called "RePaint" after changing the image, tried to use a third ImageMan control just to process these adjustments, etc. No luck.

Any suggestions will be greatly appreciated.

1 Data Techniques Response

Up -2 Rated Down
DTI Support  Data Techniques Employee Sep 04, 2013 12:15PM EDT


Can you send us an image you load and then the image you have created ? Please email to so we can see whats happening.

Data Techniques

This question is closed to new answers.

Contact Us