]> Pileus Git - ~andy/gtk/blob - gdk-pixbuf/io-bmp.c
503747bcb1bb287f7df098d9c6f96091e981786d
[~andy/gtk] / gdk-pixbuf / io-bmp.c
1 /*
2  * io-bmp.c: GdkPixBuf I/O for BMP files.
3  *
4  * Copyright (C) 1999 Mark Crichton
5  * Author: Mark Crichton <crichton@gimp.org>
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Library General Public
9  * License as published by the Free Software Foundation; either
10  * version 2 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Library General Public License for more details.
16  *
17  * You should have received a copy of the GNU Library General Public
18  * License along with this library; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place - Suite 330, Cambridge, MA 02139, USA.
20  *
21  */
22
23 #include <config.h>
24 #include <stdio.h>
25 #include <glib.h>
26 #include "gdk-pixbuf.h"
27 #include "gdk-pixbuf-io.h"
28 #include "io-bmp.h"
29
30 /* Loosely based off the BMP loader from The GIMP, hence it's complexity */
31
32 /* Shared library entry point */
33 GdkPixBuf *image_load(FILE * f)
34 {
35     GdkPixBuf *pixbuf;
36     art_u8 *pixels;
37
38     /* Ok, now stuff the GdkPixBuf with goodies */
39
40     pixbuf = g_new(GdkPixBuf, 1);
41
42     if (is_trans)
43         pixbuf->art_pixbuf = art_pixbuf_new_rgba(pixels, w, h, (w * 4));
44     else
45         pixbuf->art_pixbuf = art_pixbuf_new_rgb(pixels, w, h, (w * 3));
46
47     /* Ok, I'm anal...shoot me */
48     if (!(pixbuf->art_pixbuf))
49         return NULL;
50     pixbuf->ref_count = 1;
51     pixbuf->unref_func = NULL;
52
53     return pixbuf;
54 }