diff options
author | Lutz Mueller <lutz@users.sourceforge.net> | 2004-05-02 21:06:50 +0000 |
---|---|---|
committer | Lutz Mueller <lutz@users.sourceforge.net> | 2004-05-02 21:06:50 +0000 |
commit | f001ba7d858d3cf58b2056326d25751d9de6cac2 (patch) | |
tree | 3e206f3b597ef07f38af384d9d81ea681b501d07 /camlibs/casio | |
parent | c0a392922302377c0e3927db89bce3443aff9f96 (diff) | |
download | libgphoto2-f001ba7d858d3cf58b2056326d25751d9de6cac2.tar.gz |
2004-05-02 Lutz Mueller <lutz@users.sourceforge.net>
* ycctoppm.[c,h]: New files on request of Micael Haardt.
* Makefile.am
git-svn-id: https://svn.code.sf.net/p/gphoto/code/trunk/libgphoto2@7194 67ed7778-7388-44ab-90cf-0a291f65f57c
Diffstat (limited to 'camlibs/casio')
-rw-r--r-- | camlibs/casio/ChangeLog | 5 | ||||
-rw-r--r-- | camlibs/casio/Makefile.am | 3 | ||||
-rw-r--r-- | camlibs/casio/ycctoppm.c | 90 | ||||
-rw-r--r-- | camlibs/casio/ycctoppm.h | 27 |
4 files changed, 124 insertions, 1 deletions
diff --git a/camlibs/casio/ChangeLog b/camlibs/casio/ChangeLog index 2e76f34c9..a37e8d309 100644 --- a/camlibs/casio/ChangeLog +++ b/camlibs/casio/ChangeLog @@ -1,3 +1,8 @@ +2004-05-02 Lutz Mueller <lutz@users.sourceforge.net> + + * ycctoppm.[c,h]: New files on request of Micael Haardt. + * Makefile.am + 2004-04-06 Lutz Mueller <lutz@users.sourceforge.net> * cam2jpgtab.h: New. diff --git a/camlibs/casio/Makefile.am b/camlibs/casio/Makefile.am index 2b2ac0177..dcbdcd5ab 100644 --- a/camlibs/casio/Makefile.am +++ b/camlibs/casio/Makefile.am @@ -9,7 +9,8 @@ libgphoto2_casio_qv_la_SOURCES = \ casio-qv.c \ casio-qv-commands.c casio-qv-commands.h \ camtojpeg.c camtojpeg.h \ - cam2jpgtab.h jpegtab_f.h + cam2jpgtab.h jpegtab_f.h \ + ycctoppm.c ycctoppm.h libgphoto2_casio_qv_la_LDFLAGS = -module -avoid-version libgphoto2_casio_qv_la_LIBADD = $(top_builddir)/libgphoto2/libgphoto2.la diff --git a/camlibs/casio/ycctoppm.c b/camlibs/casio/ycctoppm.c new file mode 100644 index 000000000..0ba1c2e79 --- /dev/null +++ b/camlibs/casio/ycctoppm.c @@ -0,0 +1,90 @@ +/* ycctoppm.c + * + * Copyright (c) 2004 Michael Haardt + * + * 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 2 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, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#include "config.h" + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#include <gphoto2-library.h> + +#include "ycctoppm.h" + +#define THUMBNAIL_WIDTH 52 +#define THUMBNAIL_HEIGHT 36 + +#define RATE_H 2 + +int QVycctoppm(const unsigned char *ycc, long int yccSize, int width, int height, int ratew, unsigned char **ppm, long int *ppmSize) +{ + char header[64]; + size_t headerSize; + unsigned char *dst; + int x, y; + long cr, cb; + long L; + long r,g,b; + unsigned char *Y; + unsigned char *Cr; + unsigned char *Cb; + + snprintf(header,sizeof(header),"P6\n%d %d\n255\n",width,height); + headerSize=strlen(header); + + *ppm=malloc(*ppmSize=(headerSize+3*width*height)); + + dst=*ppm; + memcpy(dst,header,headerSize); dst+=headerSize; + + Y = ycc; + Cb = Y + (height * width); + Cr = Cb + (height / RATE_H) * (width / ratew); + + for (y=0; y<height; ++y) + { + for (x=0; x<width; ++x) + { + L = Y[y * width + x] * 100000; + cb = Cb[(y/RATE_H) * width/ratew + x/ratew]; + if (cb > 127) cb = cb - 256; + cr = Cr[(y/RATE_H) * width/ratew + x/ratew]; + if (cr > 127) cr = cr - 256; + + r = L + 140200 * cr; + g = L - 34414 * cb - 71414 * cr; + b = L + 177200 * cb; + + r = r / 100000; + g = g / 100000; + b = b / 100000; + + if (r<0) r=0; else if (r>255) r=255; + if (g<0) g=0; else if (g>255) g=255; + if (b<0) b=0; else if (b>255) b=255; + + *dst++ = r; + *dst++ = g; + *dst++ = b; + } + } + + return GP_OK; +} diff --git a/camlibs/casio/ycctoppm.h b/camlibs/casio/ycctoppm.h new file mode 100644 index 000000000..8e34ded4c --- /dev/null +++ b/camlibs/casio/ycctoppm.h @@ -0,0 +1,27 @@ +/* ycctoppm.h + * + * Copyright (c) 2004 Michael Haardt + * + * 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 2 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, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#ifndef __CASIO_QV_YCCTOPPM_H__ +#define __CASIO_QV_YCCTOPPM_H__ + +int QVycctoppm(const unsigned char *ycc, long int yccSize, int width, int height, int ratew, unsigned char **ppm, long int *ppmSize); + +#endif + |