Git-Url: 
http://git.frugalware.org/gitweb/gitweb.cgi?p=fwpl.git;a=commitdiff;h=1debee2d7aa845349ba077e3ebd1cc2014844850

commit 1debee2d7aa845349ba077e3ebd1cc2014844850
Author: James Buren <r...@frugalware.org>
Date:   Sun Oct 18 22:35:47 2009 -0500

image.c
* initial draft

diff --git a/src/c/image.c b/src/c/image.c
new file mode 100644
index 0000000..6b60a33
--- /dev/null
+++ b/src/c/image.c
@@ -0,0 +1,65 @@
+//[of]:includes
+#include <stdlib.h>
+#include <gd.h>
+#include <iso646.h>
+#include <assert.h>
+#include "utility.h"
+#include "image.h"
+//[cf]
+//[of]:types
+struct TImage {
+  gdImagePtr data;
+};
+//[cf]
+//[of]:functions
+//[of]:image_create
+PImage image_create(int width,int height) {
+  PImage image;
+
+  assert((width > 0) and (height > 0));
+
+  alloc(image,1);
+
+  image->data = gdImageCreateTrueColor(width,height);
+
+  if(image->data == NULL) {
+    fprintf(stderr,"Failed to create image of %d pixels by %d 
pixels.\n",width,height);
+    abort();
+  }
+
+  return image;
+}
+//[cf]
+//[of]:image_destroy
+void image_destroy(PImage image) {
+  assert(image != NULL);
+
+  gdImageDestroy(image->data);
+
+  free(image);
+}
+//[cf]
+//[of]:image_get_width
+int image_get_width(PImage image) {
+  assert(image != NULL);
+
+  return gdImageSX(image->data);
+}
+//[cf]
+//[of]:image_get_height
+int image_get_height(PImage image) {
+  assert(image != NULL);
+
+  return gdImageSY(image->data);
+}
+//[cf]
+//[of]:image_get_dimensions
+void image_get_dimensions(PImage image,PInt width,PInt height) {
+  assert(image != NULL);
+
+  (*width) = gdImageSX(image->data);
+
+  (*height) = gdImageSY(image->data);
+}
+//[cf]
+//[cf]
_______________________________________________
Frugalware-git mailing list
Frugalware-git@frugalware.org
http://frugalware.org/mailman/listinfo/frugalware-git

Reply via email to