  
    
main.htmlMain Page     
classes.htmlData Structures     
files.htmlFiles     
dirs.htmlDirectories   
  
    
files.htmlFile List     
globals.htmlGlobals   
dir_3c4fde49625df9344590fff295c7c38d.htmllibexif exif-utils.c
exif-utils_8c.htmlGo to the documentation of this file. 00001 /* exif-utils.c 00002  * 00003  * Copyright © 2001 Lutz Müller <lutz@users.sourceforge.net> 00004  * 00005  * This library is free software; you can redistribute it and/or 00006  * modify it under the terms of the GNU Lesser General Public 00007  * License as published by the Free Software Foundation; either 00008  * version 2 of the License, or (at your option) any later version. 00009  * 00010  * This library is distributed in the hope that it will be useful, 00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 00013  * Lesser General Public License for more details. 00014  * 00015  * You should have received a copy of the GNU Lesser General Public 00016  * License along with this library; if not, write to the 00017  * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 00018  * Boston, MA 02111-1307, USA. 00019  */ 00020 
00021 #include <config.h> 00022 
00023 #include < exif-utils_8h.htmllibexif/exif-utils.h > 00024 
00025 void exif-utils_8h.html#72ec39e4434b91da06044a5c5a1bc0a000026  exif-utils_8c.html#54ef3b86ffeb643e9c4434b85ccf2992exif_array_set_byte_order  ( exif-format_8h.html#761152047d73b4a9fcdc4e2051b817d2ExifFormat  f, unsigned char *b, unsigned int n,
00027                 exif-byte-order_8h.html#f966227d69ff74eea7ecd69ca645155bExifByteOrder  o_orig, exif-byte-order_8h.html#f966227d69ff74eea7ecd69ca645155bExifByteOrder  o_new)
00028 {
00029         unsigned int j;
00030         unsigned int fs = exif-format_8c.html#924038efe0cd8ebade8f44619dd794f3exif_format_get_size  (f);
00031         exif-utils_8h.html#398536727127a9bc2206ffbdacaafaadExifShort  s;
00032         exif-utils_8h.html#67d91a929ae0a1b734ced5f497428d3bExifSShort  ss;
00033         exif-utils_8h.html#34c5d7765ab2e6dec8308c5127a10afaExifLong  l;
00034         exif-utils_8h.html#34d3e46cb03b44374e56984e6a983019ExifSLong  sl;
00035         structExifRational.htmlExifRational  r;
00036         structExifSRational.htmlExifSRational  sr;
00037 
00038         if (!b || !n || !fs) return;
00039 
00040         switch (f) {
00041         case exif-format_8h.html#761152047d73b4a9fcdc4e2051b817d25f22efb2ec9e3bd9e29faa87cd7b64e5EXIF_FORMAT_SHORT :
00042                 for (j = 0; j < n; j++) {
00043                         s = exif-utils_8c.html#4b4acf537a8c6b9405e7b53be868e4d7exif_get_short  (b + j * fs, o_orig);
00044                         exif-utils_8c.html#d905d16e26b4052a1db34dbebdc37341exif_set_short  (b + j * fs, o_new, s);
00045                 }
00046                 break;
00047         case exif-format_8h.html#761152047d73b4a9fcdc4e2051b817d285dbf2985c5d03f406746f0b0cf1cbbeEXIF_FORMAT_SSHORT :
00048                 for (j = 0; j < n; j++) {
00049                         ss = exif-utils_8c.html#6baf094a71392f9cea23ad633ec13c8bexif_get_sshort  (b + j * fs, o_orig);
00050                         exif-utils_8c.html#6504651147702fc6db9a5cd4aa997023exif_set_sshort  (b + j * fs, o_new, ss);
00051                 }
00052                 break;
00053         case exif-format_8h.html#761152047d73b4a9fcdc4e2051b817d25611dcd2fcdcaf91f25412bece8485b6EXIF_FORMAT_LONG :
00054                 for (j = 0; j < n; j++) {
00055                         l = exif-utils_8c.html#4ad94614630897766dd0a5c9bc2a59bfexif_get_long  (b + j * fs, o_orig);
00056                         exif-utils_8c.html#c90147d0cc97bec7a577bf9576191bf8exif_set_long  (b + j * fs, o_new, l);
00057                 }
00058                 break;
00059         case exif-format_8h.html#761152047d73b4a9fcdc4e2051b817d22712817194f241cb15f19e5a77d2bf42EXIF_FORMAT_RATIONAL :
00060                 for (j = 0; j < n; j++) {
00061                         r = exif-utils_8c.html#1feb547c289aa57a4d2119338b03706cexif_get_rational  (b + j * fs, o_orig);
00062                         exif-utils_8c.html#400a16b1754150f721e9fca67ad89a52exif_set_rational  (b + j * fs, o_new, r);
00063                 }
00064                 break;
00065         case exif-format_8h.html#761152047d73b4a9fcdc4e2051b817d21e5c296e5c3a2e39eeb87d0a26597f87EXIF_FORMAT_SLONG :
00066                 for (j = 0; j < n; j++) {
00067                         sl = exif-utils_8c.html#56b96f076a13da6ed926e1ef29cb2dc3exif_get_slong  (b + j * fs, o_orig);
00068                         exif-utils_8c.html#e6e3b9d1663f9ab9bd462d73a310ca03exif_set_slong  (b + j * fs, o_new, sl);
00069                 }
00070                 break;
00071         case exif-format_8h.html#761152047d73b4a9fcdc4e2051b817d23c60fa6310f13ba77c677708ab41c29cEXIF_FORMAT_SRATIONAL :
00072                 for (j = 0; j < n; j++) {
00073                         sr = exif-utils_8c.html#db97c3499488d5642a82df1cb16dc2cbexif_get_srational  (b + j * fs, o_orig);
00074                         exif-utils_8c.html#ca1790a72b1833dff1b0bf728052c3c5exif_set_srational  (b + j * fs, o_new, sr);
00075                 }
00076                 break;
00077         case exif-format_8h.html#761152047d73b4a9fcdc4e2051b817d25ce63b2dc5a1db046bcd130bb0eff2bcEXIF_FORMAT_UNDEFINED :
00078         case exif-format_8h.html#761152047d73b4a9fcdc4e2051b817d2fdf39e6e5864897d50e52419fbe48356EXIF_FORMAT_BYTE :
00079         case exif-format_8h.html#761152047d73b4a9fcdc4e2051b817d28cee3caa738d8bb85311678f0cb0e868EXIF_FORMAT_ASCII :
00080         default:
00081                 /* Nothing here. */ 00082                 break;
00083         }
00084 }
00085 
00086 exif-utils_8h.html#67d91a929ae0a1b734ced5f497428d3bExifSShort exif-utils_8h.html#6dc3475c0db42623b7088c6b05abe96100087  exif-utils_8c.html#6baf094a71392f9cea23ad633ec13c8bexif_get_sshort  (const unsigned char *buf, exif-byte-order_8h.html#f966227d69ff74eea7ecd69ca645155bExifByteOrder  order)
00088 {
00089         if (!buf) return 0;
00090         switch (order) {
00091         case exif-byte-order_8h.html#f966227d69ff74eea7ecd69ca645155bd71d87054b55fd62b0eed2c2c5e879b1EXIF_BYTE_ORDER_MOTOROLA :
00092                 return ((buf[0] << 8) | buf[1]);
00093         case exif-byte-order_8h.html#f966227d69ff74eea7ecd69ca645155b851fef40a65a105b066115210a6b40b9EXIF_BYTE_ORDER_INTEL :
00094                 return ((buf[1] << 8) | buf[0]);
00095         }
00096 
00097         /* Won't be reached */ 00098         return (0);
00099 }
00100 
00101 exif-utils_8h.html#398536727127a9bc2206ffbdacaafaadExifShort exif-utils_8h.html#4294f7900ef8e5541470e2dd6659981e00102  exif-utils_8c.html#4b4acf537a8c6b9405e7b53be868e4d7exif_get_short  (const unsigned char *buf, exif-byte-order_8h.html#f966227d69ff74eea7ecd69ca645155bExifByteOrder  order)
00103 {
00104         return ( exif-utils_8c.html#6baf094a71392f9cea23ad633ec13c8bexif_get_sshort  (buf, order) & 0xffff);
00105 }
00106 
00107 void exif-utils_8h.html#6504651147702fc6db9a5cd4aa99702300108  exif-utils_8c.html#6504651147702fc6db9a5cd4aa997023exif_set_sshort  (unsigned char *b, exif-byte-order_8h.html#f966227d69ff74eea7ecd69ca645155bExifByteOrder  order, exif-utils_8h.html#67d91a929ae0a1b734ced5f497428d3bExifSShort  mnote-canon-entry_8c.html#c3cc58975ec017f769b62d6e100e4d06value )
00109 {
00110         if (!b) return;
00111         switch (order) {
00112         case exif-byte-order_8h.html#f966227d69ff74eea7ecd69ca645155bd71d87054b55fd62b0eed2c2c5e879b1EXIF_BYTE_ORDER_MOTOROLA :
00113                 b[0] = (unsigned char) (value >> 8);
00114                 b[1] = (unsigned char) value;
00115                 break;
00116         case exif-byte-order_8h.html#f966227d69ff74eea7ecd69ca645155b851fef40a65a105b066115210a6b40b9EXIF_BYTE_ORDER_INTEL :
00117                 b[0] = (unsigned char) value;
00118                 b[1] = (unsigned char) (value >> 8);
00119                 break;
00120         }
00121 }
00122 
00123 void exif-utils_8h.html#d905d16e26b4052a1db34dbebdc3734100124  exif-utils_8c.html#d905d16e26b4052a1db34dbebdc37341exif_set_short  (unsigned char *b, exif-byte-order_8h.html#f966227d69ff74eea7ecd69ca645155bExifByteOrder  order, exif-utils_8h.html#398536727127a9bc2206ffbdacaafaadExifShort  mnote-canon-entry_8c.html#c3cc58975ec017f769b62d6e100e4d06value )
00125 {
00126         exif-utils_8c.html#6504651147702fc6db9a5cd4aa997023exif_set_sshort  (b, order, value);
00127 }
00128 
00129 exif-utils_8h.html#34d3e46cb03b44374e56984e6a983019ExifSLong exif-utils_8h.html#56b96f076a13da6ed926e1ef29cb2dc300130  exif-utils_8c.html#56b96f076a13da6ed926e1ef29cb2dc3exif_get_slong  (const unsigned char *b, exif-byte-order_8h.html#f966227d69ff74eea7ecd69ca645155bExifByteOrder  order)
00131 {
00132         if (!b) return 0;
00133         switch (order) {
00134         case exif-byte-order_8h.html#f966227d69ff74eea7ecd69ca645155bd71d87054b55fd62b0eed2c2c5e879b1EXIF_BYTE_ORDER_MOTOROLA :
00135                 return ((b[0] << 24) | (b[1] << 16) | (b[2] << 8) | b[3]);
00136         case exif-byte-order_8h.html#f966227d69ff74eea7ecd69ca645155b851fef40a65a105b066115210a6b40b9EXIF_BYTE_ORDER_INTEL :
00137                 return ((b[3] << 24) | (b[2] << 16) | (b[1] << 8) | b[0]);
00138         }
00139 
00140         /* Won't be reached */ 00141         return (0);
00142 }
00143 
00144 void exif-utils_8h.html#e6e3b9d1663f9ab9bd462d73a310ca0300145  exif-utils_8c.html#e6e3b9d1663f9ab9bd462d73a310ca03exif_set_slong  (unsigned char *b, exif-byte-order_8h.html#f966227d69ff74eea7ecd69ca645155bExifByteOrder  order, exif-utils_8h.html#34d3e46cb03b44374e56984e6a983019ExifSLong  mnote-canon-entry_8c.html#c3cc58975ec017f769b62d6e100e4d06value )
00146 {
00147         if (!b) return;
00148         switch (order) {
00149         case exif-byte-order_8h.html#f966227d69ff74eea7ecd69ca645155bd71d87054b55fd62b0eed2c2c5e879b1EXIF_BYTE_ORDER_MOTOROLA :
00150                 b[0] = (unsigned char) (value >> 24);
00151                 b[1] = (unsigned char) (value >> 16);
00152                 b[2] = (unsigned char) (value >> 8);
00153                 b[3] = (unsigned char) value;
00154                 break;
00155         case exif-byte-order_8h.html#f966227d69ff74eea7ecd69ca645155b851fef40a65a105b066115210a6b40b9EXIF_BYTE_ORDER_INTEL :
00156                 b[3] = (unsigned char) (value >> 24);
00157                 b[2] = (unsigned char) (value >> 16);
00158                 b[1] = (unsigned char) (value >> 8);
00159                 b[0] = (unsigned char) value;
00160                 break;
00161         }
00162 }
00163 
00164 exif-utils_8h.html#34c5d7765ab2e6dec8308c5127a10afaExifLong exif-utils_8h.html#ade6b72dc606bf6d36d684353ddc16dd00165  exif-utils_8c.html#4ad94614630897766dd0a5c9bc2a59bfexif_get_long  (const unsigned char *buf, exif-byte-order_8h.html#f966227d69ff74eea7ecd69ca645155bExifByteOrder  order)
00166 {
00167         return ( exif-utils_8c.html#56b96f076a13da6ed926e1ef29cb2dc3exif_get_slong  (buf, order) & 0xffffffff);
00168 }
00169 
00170 void exif-utils_8h.html#c90147d0cc97bec7a577bf9576191bf800171  exif-utils_8c.html#c90147d0cc97bec7a577bf9576191bf8exif_set_long  (unsigned char *b, exif-byte-order_8h.html#f966227d69ff74eea7ecd69ca645155bExifByteOrder  order, exif-utils_8h.html#34c5d7765ab2e6dec8308c5127a10afaExifLong  mnote-canon-entry_8c.html#c3cc58975ec017f769b62d6e100e4d06value )
00172 {
00173         exif-utils_8c.html#e6e3b9d1663f9ab9bd462d73a310ca03exif_set_slong  (b, order, value);
00174 }
00175 
00176 structExifSRational.htmlExifSRational exif-utils_8h.html#1934d7118f86a4791ba35f92c9c95a3100177  exif-utils_8c.html#db97c3499488d5642a82df1cb16dc2cbexif_get_srational  (const unsigned char *buf, exif-byte-order_8h.html#f966227d69ff74eea7ecd69ca645155bExifByteOrder  order)
00178 {
00179         structExifSRational.htmlExifSRational  r;
00180 
00181         r. structExifSRational.html#a815271c1e4470a0179a4329789c79benumerator    = buf ? exif-utils_8c.html#56b96f076a13da6ed926e1ef29cb2dc3exif_get_slong  (buf, order) : 0;
00182         r. structExifSRational.html#dd1d6a0cb9f022dba76e984c7dbc65d7denominator  = buf ? exif-utils_8c.html#56b96f076a13da6ed926e1ef29cb2dc3exif_get_slong  (buf + 4, order) : 0;
00183 
00184         return (r);
00185 }
00186 
00187 structExifRational.htmlExifRational exif-utils_8h.html#f813a7082b2eb2f24975d88b1a05f0df00188  exif-utils_8c.html#1feb547c289aa57a4d2119338b03706cexif_get_rational  (const unsigned char *buf, exif-byte-order_8h.html#f966227d69ff74eea7ecd69ca645155bExifByteOrder  order)
00189 {
00190         structExifRational.htmlExifRational  r;
00191 
00192         r. structExifRational.html#f0b91792fb6f2a858be8ca9ae6795a19numerator    = buf ? exif-utils_8c.html#4ad94614630897766dd0a5c9bc2a59bfexif_get_long  (buf, order) : 0;
00193         r. structExifRational.html#2c32f17876dd1f86a1869450946be56bdenominator  = buf ? exif-utils_8c.html#4ad94614630897766dd0a5c9bc2a59bfexif_get_long  (buf + 4, order) : 0;
00194 
00195         return (r);
00196 }
00197 
00198 void exif-utils_8h.html#a299934dee6585bc65fbd88bdea1cbdf00199  exif-utils_8c.html#400a16b1754150f721e9fca67ad89a52exif_set_rational  (unsigned char *buf, exif-byte-order_8h.html#f966227d69ff74eea7ecd69ca645155bExifByteOrder  order,
00200                    structExifRational.htmlExifRational  mnote-canon-entry_8c.html#c3cc58975ec017f769b62d6e100e4d06value )
00201 {
00202         if (!buf) return;
00203         exif-utils_8c.html#c90147d0cc97bec7a577bf9576191bf8exif_set_long  (buf, order, mnote-canon-entry_8c.html#c3cc58975ec017f769b62d6e100e4d06value .numerator);
00204         exif-utils_8c.html#c90147d0cc97bec7a577bf9576191bf8exif_set_long  (buf + 4, order, mnote-canon-entry_8c.html#c3cc58975ec017f769b62d6e100e4d06value .denominator);
00205 }
00206 
00207 void exif-utils_8h.html#a88a2d05131c7073aafdc4cd4ae709b300208  exif-utils_8c.html#ca1790a72b1833dff1b0bf728052c3c5exif_set_srational  (unsigned char *buf, exif-byte-order_8h.html#f966227d69ff74eea7ecd69ca645155bExifByteOrder  order,
00209                     structExifSRational.htmlExifSRational  mnote-canon-entry_8c.html#c3cc58975ec017f769b62d6e100e4d06value )
00210 {
00211         if (!buf) return;
00212         exif-utils_8c.html#e6e3b9d1663f9ab9bd462d73a310ca03exif_set_slong  (buf, order, mnote-canon-entry_8c.html#c3cc58975ec017f769b62d6e100e4d06value .numerator);
00213         exif-utils_8c.html#e6e3b9d1663f9ab9bd462d73a310ca03exif_set_slong  (buf + 4, order, mnote-canon-entry_8c.html#c3cc58975ec017f769b62d6e100e4d06value .denominator);
00214 }
Generated on Sun Apr 23 02:19:19 2006 for EXIF library (libexif) Internals by 
http://www.doxygen.org/index.htmldoxygen  1.4.6 