2008年10月23日星期四

ArcEngine 打印输出中添加图片的问题

pPicEle.ImportPictureFromFile(pPicturePath)
导入JPG文件或其他不是bmp文件出现错误,解决方法在ESRI论坛上,引用如下:
Function GetJpeg(sPath As String) As IElement
Dim pRasterPict As IRasterPicture
Dim pOLEPict As IOlePictureElement
Set pRasterPict = New RasterPicture
Set pOLEPict = New BmpPictureElement
pOLEPict.ImportPicture pRasterPict.LoadPicture(sPath)
Set GetJpeg = pOLEPict
End Function
Private Sub logo_Click()
Dim pMxDoc As IMxDocument
Dim pactiveview As IActiveView
Dim ppagelayout As IPageLayout
Dim pgraphicscontainer As IGraphicsContainer
Dim pElement As IElement
Dim ppictureelement As IPictureElement
Dim penvelope As IEnvelope
Set pElement = GetJpeg("d:\arcgis\toolbar\image\bowater.jpg")
If TypeOf pElement Is IPictureElement Then
Set ppictureelement = pElement
ppictureelement.MaintainAspectRatio = True
ppictureelement.SavePictureInDocument = True
End If
Set pMxDoc = ThisDocument
Set pgraphicscontainer = pMxDoc.PageLayout
Set penvelope = pMxDoc.PageLayout.Page.PrintableBounds
penvelope.XMax = ((penvelope.XMax - penvelope.XMin) / 2)
penvelope.XMin = 1
penvelope.YMax = penvelope.YMax - 1
penvelope.YMin = penvelope.YMax - ((penvelope.XMax - penvelope.XMin) / 4.73)
pElement.Geometry = penvelope
pgraphicscontainer.AddElement ppictureelement, 0
Set pMxDoc.ActiveView = pMxDoc.PageLayout
pMxDoc.ActiveView.Refresh
Else
End Sub

没有评论: