aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJohn Hawthorn <jhawthor@uvic.ca>2008-06-24 19:22:56 -0700
committerJohn Hawthorn <jhawthor@uvic.ca>2008-06-24 19:22:56 -0700
commit07e510dd35cfa682d29dfdbaf02bdf5f31073f2c (patch)
treeaca641be4849607b3ef2ef16ba410c883485f691 /src
parent9d75e2050e8863cd42875a56c5d16c3c4716eadf (diff)
downloadmirror-meh-07e510dd35cfa682d29dfdbaf02bdf5f31073f2c.tar.gz
mirror-meh-07e510dd35cfa682d29dfdbaf02bdf5f31073f2c.tar.bz2
mirror-meh-07e510dd35cfa682d29dfdbaf02bdf5f31073f2c.zip
cleanup
Diffstat (limited to 'src')
-rw-r--r--src/bmp.c36
-rw-r--r--src/main.c4
-rw-r--r--src/png.c33
3 files changed, 37 insertions, 36 deletions
diff --git a/src/bmp.c b/src/bmp.c
index 89d9310..e071c15 100644
--- a/src/bmp.c
+++ b/src/bmp.c
@@ -4,22 +4,6 @@
#include "meh.h"
-unsigned short getshort(FILE *f){
- unsigned short ret;
- ret = getc(f);
- ret = ret | (getc(f) << 8);
- return ret;
-}
-
-unsigned long getlong(FILE *f){
- unsigned short ret;
- ret = getc(f);
- ret = ret | (getc(f) << 8);
- ret = ret | (getc(f) << 16);
- ret = ret | (getc(f) << 24);
- return ret;
-}
-
struct rgb_t{
unsigned char r, g, b;
};
@@ -34,6 +18,22 @@ struct bmp_t{
unsigned int rowwidth;
};
+static unsigned short getshort(FILE *f){
+ unsigned short ret;
+ ret = getc(f);
+ ret = ret | (getc(f) << 8);
+ return ret;
+}
+
+static unsigned long getlong(FILE *f){
+ unsigned short ret;
+ ret = getc(f);
+ ret = ret | (getc(f) << 8);
+ ret = ret | (getc(f) << 16);
+ ret = ret | (getc(f) << 24);
+ return ret;
+}
+
struct image *bmp_open(FILE *f){
struct bmp_t *b;
unsigned long headersize;
@@ -103,7 +103,7 @@ struct image *bmp_open(FILE *f){
return (struct image *)b;
}
-void rgb16(unsigned char *buf, unsigned short c){
+static void rgb16(unsigned char *buf, unsigned short c){
int i;
for(i = 0; i < 3; i++){
*buf++ = ((c >> (i * 5)) & 0x1f) << 3;
@@ -170,7 +170,7 @@ int bmp_read(struct image *img){
return 0;
}
-struct imageformat gif = {
+struct imageformat bmp = {
bmp_open,
bmp_read
};
diff --git a/src/main.c b/src/main.c
index 29df176..9a45508 100644
--- a/src/main.c
+++ b/src/main.c
@@ -17,10 +17,10 @@ extern Display *display;
extern struct imageformat libjpeg;
extern struct imageformat giflib;
extern struct imageformat libpng;
-extern struct imageformat gif;
+extern struct imageformat bmp;
struct imageformat *formats[] = {
&libjpeg,
- &gif,
+ &bmp,
&libpng,
&giflib, /* HACK! make gif last (uses read()) */
NULL
diff --git a/src/png.c b/src/png.c
index 47e4f0e..659e935 100644
--- a/src/png.c
+++ b/src/png.c
@@ -53,6 +53,23 @@ struct image *png_open(FILE *f){
png_init_io(p->png_ptr, f);
png_read_info(p->png_ptr, p->info_ptr);
+
+ p->img.width = png_get_image_width(p->png_ptr, p->info_ptr);
+ p->img.height = png_get_image_height(p->png_ptr, p->info_ptr);
+
+ return (struct image *)p;
+}
+
+int png_read(struct image *img){
+ unsigned int y;
+ png_bytepp row_pointers;
+ struct png_t *p = (struct png_t *)img;
+
+ if(setjmp(png_jmpbuf(p->png_ptr))){
+ png_destroy_read_struct(&p->png_ptr, &p->info_ptr, &p->end_info);
+ return 1;
+ }
+
{
int color_type = png_get_color_type(p->png_ptr, p->info_ptr);
int bit_depth = png_get_bit_depth(p->png_ptr, p->info_ptr);
@@ -74,22 +91,6 @@ struct image *png_open(FILE *f){
png_read_update_info(p->png_ptr, p->info_ptr);
}
- p->img.width = png_get_image_width(p->png_ptr, p->info_ptr);
- p->img.height = png_get_image_height(p->png_ptr, p->info_ptr);
-
- return (struct image *)p;
-}
-
-int png_read(struct image *img){
- unsigned int y;
- png_bytepp row_pointers;
-
- struct png_t *p = (struct png_t *)img;
- if(setjmp(png_jmpbuf(p->png_ptr))){
- png_destroy_read_struct(&p->png_ptr, &p->info_ptr, &p->end_info);
- return 1;
- }
-
row_pointers = (png_bytepp)malloc(img->height * sizeof(png_bytep));
for(y = 0; y < img->height; y++)
row_pointers[y] = img->buf + y * img->width * 3;