Browse Source

[image] Add image_pixbuf() to create pixel buffer from image

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 11 years ago
parent
commit
09f31e9fc4
2 changed files with 40 additions and 3 deletions
  1. 26
    0
      src/core/image.c
  2. 14
    3
      src/include/ipxe/image.h

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

456
 
456
 
457
 	return 0;
457
 	return 0;
458
 }
458
 }
459
+
460
+/**
461
+ * Create pixel buffer from image
462
+ *
463
+ * @v image		Image
464
+ * @v pixbuf		Pixel buffer to fill in
465
+ * @ret rc		Return status code
466
+ */
467
+int image_pixbuf ( struct image *image, struct pixel_buffer **pixbuf ) {
468
+	int rc;
469
+
470
+	/* Check that this image can be used to create a pixel buffer */
471
+	if ( ( rc = image_probe ( image ) ) != 0 )
472
+		return rc;
473
+	if ( ! image->type->pixbuf )
474
+		return -ENOTSUP;
475
+
476
+	/* Try creating pixel buffer */
477
+	if ( ( rc = image->type->pixbuf ( image, pixbuf ) ) != 0 ) {
478
+		DBGC ( image, "IMAGE %s could not create pixel buffer: %s\n",
479
+		       image->name, strerror ( rc ) );
480
+		return rc;
481
+	}
482
+
483
+	return 0;
484
+}

+ 14
- 3
src/include/ipxe/image.h View File

16
 #include <ipxe/refcnt.h>
16
 #include <ipxe/refcnt.h>
17
 
17
 
18
 struct uri;
18
 struct uri;
19
+struct pixel_buffer;
19
 struct image_type;
20
 struct image_type;
20
 
21
 
21
 /** An executable image */
22
 /** An executable image */
74
 struct image_type {
75
 struct image_type {
75
 	/** Name of this image type */
76
 	/** Name of this image type */
76
 	char *name;
77
 	char *name;
77
-	/** Probe image
78
+	/**
79
+	 * Probe image
78
 	 *
80
 	 *
79
-	 * @v image		Executable image
81
+	 * @v image		Image
80
 	 * @ret rc		Return status code
82
 	 * @ret rc		Return status code
81
 	 *
83
 	 *
82
 	 * Return success if the image is of this image type.
84
 	 * Return success if the image is of this image type.
85
 	/**
87
 	/**
86
 	 * Execute image
88
 	 * Execute image
87
 	 *
89
 	 *
88
-	 * @v image		Executable image
90
+	 * @v image		Image
89
 	 * @ret rc		Return status code
91
 	 * @ret rc		Return status code
90
 	 */
92
 	 */
91
 	int ( * exec ) ( struct image *image );
93
 	int ( * exec ) ( struct image *image );
94
+	/**
95
+	 * Create pixel buffer from image
96
+	 *
97
+	 * @v image		Image
98
+	 * @v pixbuf		Pixel buffer to fill in
99
+	 * @ret rc		Return status code
100
+	 */
101
+	int ( * pixbuf ) ( struct image *image, struct pixel_buffer **pixbuf );
92
 };
102
 };
93
 
103
 
94
 /**
104
 /**
159
 extern int image_select ( struct image *image );
169
 extern int image_select ( struct image *image );
160
 extern struct image * image_find_selected ( void );
170
 extern struct image * image_find_selected ( void );
161
 extern int image_set_trust ( int require_trusted, int permanent );
171
 extern int image_set_trust ( int require_trusted, int permanent );
172
+extern int image_pixbuf ( struct image *image, struct pixel_buffer **pixbuf );
162
 
173
 
163
 /**
174
 /**
164
  * Increment reference count on an image
175
  * Increment reference count on an image

Loading…
Cancel
Save