summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHubert Figuiere <hub@figuiere.net>2010-03-12 22:32:10 -0800
committerHubert Figuiere <hub@figuiere.net>2010-03-12 22:33:49 -0800
commit57e1f62ffbc5bb0f94e6c3ae517069db0abcd6bd (patch)
tree7c986728f16637ecc9426a1aed5c39254af9392f
parentad8ecfb0f19a40e9757af68cba87d219f18dbbdd (diff)
API: or_rawfile_get_rendered_image() returns a ORBitmapDataRef withapibreak
the correct dimensions. + corrected the Gdk support for above change.
-rw-r--r--demo/pixbufload.c2
-rw-r--r--demo/ppmload.c2
-rw-r--r--gnome/pixbuf-loader.c2
-rw-r--r--lib/Makefile.am2
-rw-r--r--lib/bimedian_demosaic.cpp17
-rw-r--r--lib/bimedian_demosaic.h32
-rw-r--r--lib/demosaic.h12
-rw-r--r--lib/rawfile.cpp8
8 files changed, 47 insertions, 30 deletions
diff --git a/demo/pixbufload.c b/demo/pixbufload.c
index 300c522..6a6440c 100644
--- a/demo/pixbufload.c
+++ b/demo/pixbufload.c
@@ -58,7 +58,7 @@ main(int argc, char **argv)
pixbuf = gdk_pixbuf_new_from_data(or_bitmapdata_data(bitmapdata),
GDK_COLORSPACE_RGB,
FALSE, 8, x , y ,
- ( x - 2 )* 3,
+ x * 3,
pixbuf_free, bitmapdata);
}
or_rawfile_release(raw_file);
diff --git a/demo/ppmload.c b/demo/ppmload.c
index 7cf118c..cf6cf9f 100644
--- a/demo/ppmload.c
+++ b/demo/ppmload.c
@@ -54,7 +54,7 @@ main(int argc, char **argv)
printf(" --- dimensions x = %d, y = %d\n", x, y);
f = fopen("image.ppm", "wb");
fprintf(f, "P6\n");
- fprintf(f, "%d %d\n", x - 2, y);
+ fprintf(f, "%d %d\n", x, y);
fprintf(f, "255\n");
size = or_bitmapdata_data_size(bitmapdata);
diff --git a/gnome/pixbuf-loader.c b/gnome/pixbuf-loader.c
index 152e7a8..ed851dd 100644
--- a/gnome/pixbuf-loader.c
+++ b/gnome/pixbuf-loader.c
@@ -114,7 +114,7 @@ gdk_pixbuf__or_image_stop_load (gpointer data, GError **error)
pixbuf = gdk_pixbuf_new_from_data(or_bitmapdata_data(bitmapdata),
GDK_COLORSPACE_RGB,
FALSE, 8, x, y,
- (x - 2) * 3,
+ x * 3,
pixbuf_free, bitmapdata);
}
or_rawfile_release(raw_file);
diff --git a/lib/Makefile.am b/lib/Makefile.am
index 03eace2..1247dce 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -85,5 +85,5 @@ libopenraw_la_SOURCES = \
crwdecompressor.cpp \
metavalue.cpp \
unpack.cpp \
- bimedian_demosaic.cpp demosaic.h \
+ bimedian_demosaic.cpp bimedian_demosaic.h \
$(NULL)
diff --git a/lib/bimedian_demosaic.cpp b/lib/bimedian_demosaic.cpp
index 0697583..266a4c1 100644
--- a/lib/bimedian_demosaic.cpp
+++ b/lib/bimedian_demosaic.cpp
@@ -1,5 +1,5 @@
/*
- * libopenraw - demoisaic.cpp
+ * libopenraw - demosaic.cpp
*
* This library is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
@@ -30,14 +30,8 @@
#include <libopenraw/demosaic.h>
-void bimedian_demosaic (uint16_t *src, uint32_t src_x, uint32_t src_y,
- or_cfa_pattern pattern, uint8_t *dst);
+#include "bimedian_demosaic.h"
-/*
-extern "C" void or_demosaic(uint16_t*, uint32_t, uint32_t, or_cfa_pattern, uint8_t*)
-{
-}
-*/
/* Returns the median of four floats. We define the median as the average of
* the central two elements.
@@ -85,7 +79,7 @@ m4 (float a, float b, float c, float d)
*/
void
bimedian_demosaic (uint16_t *src, uint32_t src_x, uint32_t src_y,
- or_cfa_pattern pattern, uint8_t *dst)
+ or_cfa_pattern pattern, uint8_t *dst, uint32_t &out_x, uint32_t &out_y)
{
uint32_t x,y;
uint32_t offset, doffset;
@@ -110,6 +104,7 @@ bimedian_demosaic (uint16_t *src, uint32_t src_x, uint32_t src_y,
break;
}
+ out_x = out_y = 0;
src_buf = (float*)calloc(src_x * src_y, sizeof(float));
dst_buf = (float*)calloc(src_x * src_y * 3, sizeof(float));
@@ -179,7 +174,9 @@ bimedian_demosaic (uint16_t *src, uint32_t src_x, uint32_t src_y,
}
offset+=2;
}
- std::copy(dst_buf, dst_buf + (src_x * src_y * 3), dst);
+ out_x = src_x - 2;
+ out_y = src_y - 2;
+ std::copy(dst_buf, dst_buf + (out_x * out_y * 3), dst);
free(src_buf);
free(dst_buf);
}
diff --git a/lib/bimedian_demosaic.h b/lib/bimedian_demosaic.h
new file mode 100644
index 0000000..9ad2e0c
--- /dev/null
+++ b/lib/bimedian_demosaic.h
@@ -0,0 +1,32 @@
+/*
+ * libopenraw - bimedian_demosaic.h
+ *
+ * Copyright 2010 Hubert Figuiere <hub@figuiere.net>
+ *
+ * This library is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * as published by the Free Software Foundation, either version 3 of
+ * the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ */
+
+
+
+#ifndef __BIMEDIAN_DEMOSAIC_H_
+#define __BIMEDIAN_DEMOSAIC_H_
+
+
+void
+bimedian_demosaic (uint16_t *src, uint32_t src_x, uint32_t src_y,
+ or_cfa_pattern pattern, uint8_t *dst, uint32_t &out_x, uint32_t &out_y);
+
+#endif
diff --git a/lib/demosaic.h b/lib/demosaic.h
deleted file mode 100644
index 61eb8be..0000000
--- a/lib/demosaic.h
+++ /dev/null
@@ -1,12 +0,0 @@
-
-
-
-#ifndef __DEMOSAIC_H_
-#define __DEMOSAIC_H_
-
-
-void
-bimedian_demosaic (uint16_t *src, uint32_t src_x, uint32_t src_y,
- or_cfa_pattern pattern, uint8_t *dst);
-
-#endif
diff --git a/lib/rawfile.cpp b/lib/rawfile.cpp
index 9e1ac6b..b4d825a 100644
--- a/lib/rawfile.cpp
+++ b/lib/rawfile.cpp
@@ -50,7 +50,7 @@
#include "mrwfile.h"
#include "metavalue.h"
#include "exception.h"
-#include "demosaic.h"
+#include "bimedian_demosaic.h"
#include "rawfilefactory.h"
@@ -386,13 +386,12 @@ const std::vector<uint32_t> & RawFile::listThumbnailSizes(void)
Trace(DEBUG1) << "wrong data type\n";
return OR_ERROR_INVALID_FORMAT;
}
- uint32_t x,y;
+ uint32_t x,y, out_x, out_y;
or_cfa_pattern pattern;
uint16_t *src;
pattern = rawdata.cfaPattern();
x = rawdata.x();
y = rawdata.y();
- bitmapdata.setDimensions(x,y);
bitmapdata.setDataType(OR_DATA_TYPE_PIXMAP_8RGB);
uint8_t *dst = (uint8_t *)bitmapdata.allocData(sizeof(uint8_t) * 3 * x * y);
/*
@@ -405,7 +404,8 @@ const std::vector<uint32_t> & RawFile::listThumbnailSizes(void)
/* figure out how the demosaic can be plugged for a different
* algorithm */
- bimedian_demosaic(src, x, y, pattern, dst);
+ bimedian_demosaic(src, x, y, pattern, dst, out_x, out_y);
+ bitmapdata.setDimensions(out_x, out_y);
}
return ret;
}