Browse Source

[pixbuf] Enable PNG format by default

Enable IMAGE_PNG (but not IMAGE_PNM) by default, and drag in the
relevant objects only when image_pixbuf() is present in the binary.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 7 years ago
parent
commit
2afd66eb55
6 changed files with 73 additions and 31 deletions
  1. 0
    6
      src/config/config.c
  2. 39
    0
      src/config/config_pixbuf.c
  3. 1
    1
      src/config/general.h
  4. 0
    24
      src/core/image.c
  5. 32
    0
      src/core/pixbuf.c
  6. 1
    0
      src/include/ipxe/errfile.h

+ 0
- 6
src/config/config.c View File

@@ -182,12 +182,6 @@ REQUIRE_OBJECT ( efi_image );
182 182
 #ifdef IMAGE_SDI
183 183
 REQUIRE_OBJECT ( sdi );
184 184
 #endif
185
-#ifdef IMAGE_PNM
186
-REQUIRE_OBJECT ( pnm );
187
-#endif
188
-#ifdef IMAGE_PNG
189
-REQUIRE_OBJECT ( png );
190
-#endif
191 185
 
192 186
 /*
193 187
  * Drag in all requested commands

+ 39
- 0
src/config/config_pixbuf.c View File

@@ -0,0 +1,39 @@
1
+/*
2
+ * This program is free software; you can redistribute it and/or
3
+ * modify it under the terms of the GNU General Public License as
4
+ * published by the Free Software Foundation; either version 2 of the
5
+ * License, or (at your option) any later version.
6
+ *
7
+ * This program is distributed in the hope that it will be useful, but
8
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
9
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
10
+ * General Public License for more details.
11
+ *
12
+ * You should have received a copy of the GNU General Public License
13
+ * along with this program; if not, write to the Free Software
14
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
15
+ * 02110-1301, USA.
16
+ *
17
+ * You can also choose to distribute this program under the terms of
18
+ * the Unmodified Binary Distribution Licence (as given in the file
19
+ * COPYING.UBDL), provided that you have satisfied its requirements.
20
+ */
21
+
22
+FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
23
+
24
+#include <config/general.h>
25
+
26
+/** @file
27
+ *
28
+ * Pixel buffer file format configuration
29
+ *
30
+ */
31
+
32
+PROVIDE_REQUIRING_SYMBOL();
33
+
34
+#ifdef IMAGE_PNM
35
+REQUIRE_OBJECT ( pnm );
36
+#endif
37
+#ifdef IMAGE_PNG
38
+REQUIRE_OBJECT ( png );
39
+#endif

+ 1
- 1
src/config/general.h View File

@@ -111,7 +111,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
111 111
 //#define	IMAGE_EFI		/* EFI image support */
112 112
 //#define	IMAGE_SDI		/* SDI image support */
113 113
 //#define	IMAGE_PNM		/* PNM image support */
114
-//#define	IMAGE_PNG		/* PNG image support */
114
+#define	IMAGE_PNG		/* PNG image support */
115 115
 #define	IMAGE_DER		/* DER image support */
116 116
 #define	IMAGE_PEM		/* PEM image support */
117 117
 

+ 0
- 24
src/core/image.c View File

@@ -481,27 +481,3 @@ int image_set_trust ( int require_trusted, int permanent ) {
481 481
 
482 482
 	return 0;
483 483
 }
484
-
485
-/**
486
- * Create pixel buffer from image
487
- *
488
- * @v image		Image
489
- * @v pixbuf		Pixel buffer to fill in
490
- * @ret rc		Return status code
491
- */
492
-int image_pixbuf ( struct image *image, struct pixel_buffer **pixbuf ) {
493
-	int rc;
494
-
495
-	/* Check that this image can be used to create a pixel buffer */
496
-	if ( ! ( image->type && image->type->pixbuf ) )
497
-		return -ENOTSUP;
498
-
499
-	/* Try creating pixel buffer */
500
-	if ( ( rc = image->type->pixbuf ( image, pixbuf ) ) != 0 ) {
501
-		DBGC ( image, "IMAGE %s could not create pixel buffer: %s\n",
502
-		       image->name, strerror ( rc ) );
503
-		return rc;
504
-	}
505
-
506
-	return 0;
507
-}

+ 32
- 0
src/core/pixbuf.c View File

@@ -30,7 +30,9 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
30 30
  */
31 31
 
32 32
 #include <stdlib.h>
33
+#include <errno.h>
33 34
 #include <ipxe/umalloc.h>
35
+#include <ipxe/image.h>
34 36
 #include <ipxe/pixbuf.h>
35 37
 
36 38
 /**
@@ -82,3 +84,33 @@ struct pixel_buffer * alloc_pixbuf ( unsigned int width, unsigned int height ) {
82 84
  err_alloc_pixbuf:
83 85
 	return NULL;
84 86
 }
87
+
88
+/**
89
+ * Create pixel buffer from image
90
+ *
91
+ * @v image		Image
92
+ * @v pixbuf		Pixel buffer to fill in
93
+ * @ret rc		Return status code
94
+ */
95
+int image_pixbuf ( struct image *image, struct pixel_buffer **pixbuf ) {
96
+	int rc;
97
+
98
+	/* Check that this image can be used to create a pixel buffer */
99
+	if ( ! ( image->type && image->type->pixbuf ) )
100
+		return -ENOTSUP;
101
+
102
+	/* Try creating pixel buffer */
103
+	if ( ( rc = image->type->pixbuf ( image, pixbuf ) ) != 0 ) {
104
+		DBGC ( image, "IMAGE %s could not create pixel buffer: %s\n",
105
+		       image->name, strerror ( rc ) );
106
+		return rc;
107
+	}
108
+
109
+	return 0;
110
+}
111
+
112
+/* Drag in objects via image_pixbuf() */
113
+REQUIRING_SYMBOL ( image_pixbuf );
114
+
115
+/* Drag in pixel buffer image formats */
116
+REQUIRE_OBJECT ( config_pixbuf );

+ 1
- 0
src/include/ipxe/errfile.h View File

@@ -70,6 +70,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
70 70
 #define ERRFILE_ansicoldef	       ( ERRFILE_CORE | 0x001e0000 )
71 71
 #define ERRFILE_fault		       ( ERRFILE_CORE | 0x001f0000 )
72 72
 #define ERRFILE_blocktrans	       ( ERRFILE_CORE | 0x00200000 )
73
+#define ERRFILE_pixbuf		       ( ERRFILE_CORE | 0x00210000 )
73 74
 
74 75
 #define ERRFILE_eisa		     ( ERRFILE_DRIVER | 0x00000000 )
75 76
 #define ERRFILE_isa		     ( ERRFILE_DRIVER | 0x00010000 )

Loading…
Cancel
Save