2
* libopenraw - ppmload.c
4
* Copyright (C) 2007, 2010 Hubert Figuiere
6
* This library is free software; you can redistribute it and/or
7
* modify it under the terms of the GNU Lesser General Public
8
* License as published by the Free Software Foundation; either
9
* version 2.1 of the License, or (at your option) any later version.
11
* This library is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
* Lesser General Public License for more details.
16
* You should have received a copy of the GNU Lesser General Public
17
* License along with this library; if not, write to the Free Software
18
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
26
#include <libopenraw/libopenraw.h>
29
main(int argc, char **argv)
39
or_debug_set_level(DEBUG2);
41
if(filename && *filename) {
42
ORRawFileRef raw_file = or_rawfile_new(filename, OR_RAWFILE_TYPE_UNKNOWN);
46
ORBitmapDataRef bitmapdata = or_bitmapdata_new();
47
err = or_rawfile_get_rendered_image(raw_file, bitmapdata, 0);
48
if(err == OR_ERROR_NONE) {
51
size_t size, written_size;
53
or_bitmapdata_dimensions(bitmapdata, &x, &y);
54
printf(" --- dimensions x = %d, y = %d\n", x, y);
55
f = fopen("image.ppm", "wb");
57
fprintf(f, "%d %d\n", x - 2, y);
60
size = or_bitmapdata_data_size(bitmapdata);
61
printf(" --- size = %ld\n", (long)size);
62
written_size = fwrite(or_bitmapdata_data(bitmapdata), 1, size, f);
63
if(written_size != size) {
64
printf("short read\n");
68
or_bitmapdata_release(bitmapdata);
69
or_rawfile_release(raw_file);
73
printf("No input file name\n");