Spanish Insertar Imagenes con PDFWriter sin OutOfMemory

hibrid0

Active Member
Licensed User
Longtime User
Comparto pequeña rutina para insertar imágenes con la Liberia PDFWriter.
Si se insertan muchas imágenes el PDFWriter sale el dichoso error de OutOfMemory.

B4X:
Sub insertar_imagen2 (nombre_imagen As String, izquierda As Double, arriba As Double)
dim img_load as bitmap
    img_Logo=LoadBitmapSample("", nombre_imagen,239, 180)

    img_Logo=CreateScaledBitmap(img_Logo, 239, 180,True)
    PDFWriter1.addImage(mm2Points(izquierda),mm2Points(arriba), img_Logo)
Log("Liberamos Memoria")      
Dim Obj1,obj2 As Reflector
      Obj1.Target = img_Logo                                        
      Obj1.RunMethod("recycle")
End Sub



La librería también da OutOfMemory cuando la imagen insertada esta fuera de la pagina creada, el error solo dice OutOfMemory y me costo tiempo saber de donde provenía el error.

Otra Rutina que hay en el foro para usar milímetros o Pulgadas con esta librería.



B4X:
Sub Points2mm(nPoints As Double) As Int
  Dim nD As Double
   Dim nL As Long
   nD = nPoints / 72 * 25.4 ' 25.4 mm = 1 Inch = 72 Point
   nL = Round(nD)
   Return nL
End Sub

Sub mm2Points(nMM As Double) As Int
  Dim nD As Double
   Dim nL As Long
   nD = nMM * 72 / 25.4
   nL = Round(nD)
   Return nL
End Sub
 
Top