r4252 adamblokus - in /branches/libharu/adamblokus: include/hpdf.h include/hpdf_image.h src/hpdf_doc.c src/hpdf_doc_png.c src/hpdf_image.c

netsurf at semichrome.net netsurf at semichrome.net
Tue Jun 3 16:20:47 BST 2008


Author: adamblokus
Date: Tue Jun  3 10:20:47 2008
New Revision: 4252

URL: http://source.netsurf-browser.org?rev=4252&view=rev
Log:
First changes to Haru - added functions for loading jpeg and png files from memory buffers.


Modified:
    branches/libharu/adamblokus/include/hpdf.h
    branches/libharu/adamblokus/include/hpdf_image.h
    branches/libharu/adamblokus/src/hpdf_doc.c
    branches/libharu/adamblokus/src/hpdf_doc_png.c
    branches/libharu/adamblokus/src/hpdf_image.c

Modified: branches/libharu/adamblokus/include/hpdf.h
URL: http://source.netsurf-browser.org/branches/libharu/adamblokus/include/hpdf.h?rev=4252&r1=4251&r2=4252&view=diff
==============================================================================
--- branches/libharu/adamblokus/include/hpdf.h (original)
+++ branches/libharu/adamblokus/include/hpdf.h Tue Jun  3 10:20:47 2008
@@ -473,6 +473,11 @@
 /*----- image data ---------------------------------------------------------*/
 
 HPDF_EXPORT(HPDF_Image)
+HPDF_LoadPngImageFromMem  (HPDF_Doc     pdf,
+                            const HPDF_BYTE *buffer,
+			   HPDF_UINT size);
+
+HPDF_EXPORT(HPDF_Image)
 HPDF_LoadPngImageFromFile (HPDF_Doc      pdf,
                            const char    *filename);
 
@@ -485,6 +490,11 @@
 HPDF_EXPORT(HPDF_Image)
 HPDF_LoadJpegImageFromFile (HPDF_Doc      pdf,
                             const char    *filename);
+
+HPDF_EXPORT(HPDF_Image)
+HPDF_LoadJpegImageFromMem   (HPDF_Doc      pdf,
+                            const HPDF_BYTE *buffer,
+			    HPDF_UINT size);
 
 HPDF_EXPORT(HPDF_Image)
 HPDF_LoadU3DFromFile (HPDF_Doc      pdf,

Modified: branches/libharu/adamblokus/include/hpdf_image.h
URL: http://source.netsurf-browser.org/branches/libharu/adamblokus/include/hpdf_image.h?rev=4252&r1=4251&r2=4252&view=diff
==============================================================================
--- branches/libharu/adamblokus/include/hpdf_image.h (original)
+++ branches/libharu/adamblokus/include/hpdf_image.h Tue Jun  3 10:20:47 2008
@@ -39,6 +39,11 @@
                            HPDF_Stream      jpeg_data,
                            HPDF_Xref        xref);
 
+HPDF_Image
+HPDF_Image_LoadJpegImageFromMem  (HPDF_MMgr        mmgr,
+                           	  const HPDF_BYTE *buf,
+				  HPDF_UINT	   size,
+                          	  HPDF_Xref        xref);
 
 HPDF_Image
 HPDF_Image_LoadRawImage  (HPDF_MMgr          mmgr,

Modified: branches/libharu/adamblokus/src/hpdf_doc.c
URL: http://source.netsurf-browser.org/branches/libharu/adamblokus/src/hpdf_doc.c?rev=4252&r1=4251&r2=4252&view=diff
==============================================================================
--- branches/libharu/adamblokus/src/hpdf_doc.c (original)
+++ branches/libharu/adamblokus/src/hpdf_doc.c Tue Jun  3 10:20:47 2008
@@ -1692,6 +1692,25 @@
     return image;
 }
 
+HPDF_EXPORT(HPDF_Image)
+HPDF_LoadJpegImageFromMem   (HPDF_Doc      pdf,
+                            const HPDF_BYTE *buffer,
+			    HPDF_UINT size)
+{
+    HPDF_Image image;
+
+    HPDF_PTRACE ((" HPDF_LoadJpegImageFromMem\n"));
+
+    if (!HPDF_HasDoc (pdf))
+        return NULL; 
+
+    image = HPDF_Image_LoadJpegImageFromMem (pdf->mmgr, buffer, size , pdf->xref);
+
+    if (!image)
+        HPDF_CheckError (&pdf->error);
+
+    return image;
+}
 
 /*----- Catalog ------------------------------------------------------------*/
 

Modified: branches/libharu/adamblokus/src/hpdf_doc_png.c
URL: http://source.netsurf-browser.org/branches/libharu/adamblokus/src/hpdf_doc_png.c?rev=4252&r1=4251&r2=4252&view=diff
==============================================================================
--- branches/libharu/adamblokus/src/hpdf_doc_png.c (original)
+++ branches/libharu/adamblokus/src/hpdf_doc_png.c Tue Jun  3 10:20:47 2008
@@ -26,6 +26,38 @@
 LoadPngImageFromStream (HPDF_Doc      pdf,
                         HPDF_Stream   imagedata,
                         HPDF_BOOL     delayed_loading);
+
+HPDF_EXPORT(HPDF_Image)
+HPDF_LoadPngImageFromMem  (HPDF_Doc     pdf,
+                           const HPDF_BYTE *buffer,
+			   HPDF_UINT size)
+{
+	HPDF_Stream imagedata;
+	HPDF_Image image;
+
+	HPDF_PTRACE ((" HPDF_LoadPngImageFromFile\n"));
+	
+	if (!HPDF_HasDoc (pdf))
+		return NULL;
+	
+	/* create file stream */
+	imagedata = HPDF_MemStream_New (pdf->mmgr, size);
+
+	if (HPDF_Stream_Write (imagedata, buffer, size) != HPDF_OK)
+        	return NULL;	
+	
+	image = LoadPngImageFromStream (pdf, imagedata, HPDF_FALSE);
+
+	/* destroy file stream */
+	if (imagedata)
+		HPDF_Stream_Free (imagedata);
+	
+	if (!image)
+		HPDF_CheckError (&pdf->error);
+	
+	return image;
+
+}
 
 
 HPDF_EXPORT(HPDF_Image)

Modified: branches/libharu/adamblokus/src/hpdf_image.c
URL: http://source.netsurf-browser.org/branches/libharu/adamblokus/src/hpdf_image.c?rev=4252&r1=4251&r2=4252&view=diff
==============================================================================
--- branches/libharu/adamblokus/src/hpdf_image.c (original)
+++ branches/libharu/adamblokus/src/hpdf_image.c Tue Jun  3 10:20:47 2008
@@ -221,6 +221,30 @@
     return image;
 }
 
+HPDF_Image
+HPDF_Image_LoadJpegImageFromMem  (HPDF_MMgr        mmgr,
+                           	  const HPDF_BYTE *buf,
+				  HPDF_UINT	   size,
+                          	  HPDF_Xref        xref)
+{
+	HPDF_Stream jpeg_data;
+	HPDF_Image image;
+
+	HPDF_PTRACE ((" HPDF_Image_LoadJpegImageFromMem\n"));
+
+	jpeg_data = HPDF_MemStream_New(mmgr,size);
+	if (HPDF_Stream_Write (jpeg_data, buf, size) != HPDF_OK)
+        	return NULL;	
+
+	image = HPDF_Image_LoadJpegImage(mmgr,jpeg_data,xref);
+
+		/* destroy file stream */
+	if (jpeg_data)
+		HPDF_Stream_Free (jpeg_data);
+
+	return image;
+}
+
 
 HPDF_Image
 HPDF_Image_LoadRawImage (HPDF_MMgr          mmgr,




More information about the netsurf-commits mailing list