소스 검색

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

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 10 년 전
부모
커밋
09f31e9fc4
2개의 변경된 파일40개의 추가작업 그리고 3개의 파일을 삭제
  1. 26
    0
      src/core/image.c
  2. 14
    3
      src/include/ipxe/image.h

+ 26
- 0
src/core/image.c 파일 보기

@@ -456,3 +456,29 @@ int image_set_trust ( int require_trusted, int permanent ) {
456 456
 
457 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 파일 보기

@@ -16,6 +16,7 @@ FILE_LICENCE ( GPL2_OR_LATER );
16 16
 #include <ipxe/refcnt.h>
17 17
 
18 18
 struct uri;
19
+struct pixel_buffer;
19 20
 struct image_type;
20 21
 
21 22
 /** An executable image */
@@ -74,9 +75,10 @@ struct image {
74 75
 struct image_type {
75 76
 	/** Name of this image type */
76 77
 	char *name;
77
-	/** Probe image
78
+	/**
79
+	 * Probe image
78 80
 	 *
79
-	 * @v image		Executable image
81
+	 * @v image		Image
80 82
 	 * @ret rc		Return status code
81 83
 	 *
82 84
 	 * Return success if the image is of this image type.
@@ -85,10 +87,18 @@ struct image_type {
85 87
 	/**
86 88
 	 * Execute image
87 89
 	 *
88
-	 * @v image		Executable image
90
+	 * @v image		Image
89 91
 	 * @ret rc		Return status code
90 92
 	 */
91 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,6 +169,7 @@ extern int image_replace ( struct image *replacement );
159 169
 extern int image_select ( struct image *image );
160 170
 extern struct image * image_find_selected ( void );
161 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 175
  * Increment reference count on an image

Loading…
취소
저장