  
    
main.htmlMain Page     
classes.htmlData Structures     
files.htmlFiles     
dirs.htmlDirectories   
  
    
files.htmlFile List     
globals.htmlGlobals   
dir_20715630405f3b63e7ab7a5c713843d9.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#6467c76dd633416fa051b5d1f4eb45e600026  exif-utils_8c.html#a54ca56c1ccaeb730631f1c1e7ce807aexif_array_set_byte_order  ( exif-format_8h.html#b34eef28c00c9728719334fa6a37bcd1ExifFormat  f, unsigned char *b, unsigned int n,
00027                 exif-byte-order_8h.html#de4a9c512c9cd4723485181c5679f1d5ExifByteOrder  o_orig, exif-byte-order_8h.html#de4a9c512c9cd4723485181c5679f1d5ExifByteOrder  o_new)
00028 {
00029         unsigned int j;
00030         unsigned int fs = exif-format_8c.html#0cd0c832a16f47c39d50aeaeb6c07e83exif_format_get_size  (f);
00031         exif-utils_8h.html#23497f35004fb9e65a70b29fd1622a9cExifShort  s;
00032         exif-utils_8h.html#2c5771b4016b8fc4cd3f93857bfe1d3dExifSShort  ss;
00033         exif-utils_8h.html#1601686195534cc6337c596fb8af54faExifLong  l;
00034         exif-utils_8h.html#afe779ceacc4b89cb135bce740185f17ExifSLong  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#b34eef28c00c9728719334fa6a37bcd16187ddb8892af4772728e34118b26a4fEXIF_FORMAT_SHORT :
00042                 for (j = 0; j < n; j++) {
00043                         s = exif-utils_8c.html#28505bc3777648fce6676fc01d74eb40exif_get_short  (b + j * fs, o_orig);
00044                         exif-utils_8c.html#3c3f4df2af5ea90902c44b23b05e20c3exif_set_short  (b + j * fs, o_new, s);
00045                 }
00046                 break;
00047         case exif-format_8h.html#b34eef28c00c9728719334fa6a37bcd174d803878ec7ffd34158ef9cc5be8714EXIF_FORMAT_SSHORT :
00048                 for (j = 0; j < n; j++) {
00049                         ss = exif-utils_8c.html#a4e89a6a836b87ad72fa45e13a41076eexif_get_sshort  (b + j * fs, o_orig);
00050                         exif-utils_8c.html#a5157a3aa1902138470f9a8d7d299216exif_set_sshort  (b + j * fs, o_new, ss);
00051                 }
00052                 break;
00053         case exif-format_8h.html#b34eef28c00c9728719334fa6a37bcd1b6f3a3c87b514af859dc91a1a1760f51EXIF_FORMAT_LONG :
00054                 for (j = 0; j < n; j++) {
00055                         l = exif-utils_8c.html#c8ce446b600340ccf5f120d8735319f3exif_get_long  (b + j * fs, o_orig);
00056                         exif-utils_8c.html#73d539019fccab7808a97c9501e3154dexif_set_long  (b + j * fs, o_new, l);
00057                 }
00058                 break;
00059         case exif-format_8h.html#b34eef28c00c9728719334fa6a37bcd19a07d82ff9979f0c075ca5c6292935d7EXIF_FORMAT_RATIONAL :
00060                 for (j = 0; j < n; j++) {
00061                         r = exif-utils_8c.html#e2e189ba31007fa57643955ec7bd3110exif_get_rational  (b + j * fs, o_orig);
00062                         exif-utils_8c.html#851d763acf065580a0872f56b5aed472exif_set_rational  (b + j * fs, o_new, r);
00063                 }
00064                 break;
00065         case exif-format_8h.html#b34eef28c00c9728719334fa6a37bcd13666b762166f1082f02d092c3fb387fbEXIF_FORMAT_SLONG :
00066                 for (j = 0; j < n; j++) {
00067                         sl = exif-utils_8c.html#00576f53c7355353ec295ddad3661ad2exif_get_slong  (b + j * fs, o_orig);
00068                         exif-utils_8c.html#0478d1f9a05e085236824fc1a0158962exif_set_slong  (b + j * fs, o_new, sl);
00069                 }
00070                 break;
00071         case exif-format_8h.html#b34eef28c00c9728719334fa6a37bcd1e9eddc5849e3352d58633256ac10caf1EXIF_FORMAT_SRATIONAL :
00072                 for (j = 0; j < n; j++) {
00073                         sr = exif-utils_8c.html#4fa17bc36688c952bba26aa81ca4fa63exif_get_srational  (b + j * fs, o_orig);
00074                         exif-utils_8c.html#88d4066528c9acebbc91444a425ea674exif_set_srational  (b + j * fs, o_new, sr);
00075                 }
00076                 break;
00077         case exif-format_8h.html#b34eef28c00c9728719334fa6a37bcd1a52e87eea3c82b9ef481cb68b95843e2EXIF_FORMAT_UNDEFINED :
00078         case exif-format_8h.html#b34eef28c00c9728719334fa6a37bcd10fe99fc897d3c96ff849052179d880f1EXIF_FORMAT_BYTE :
00079         case exif-format_8h.html#b34eef28c00c9728719334fa6a37bcd1ed05b7fe35145d01244085c176001486EXIF_FORMAT_ASCII :
00080         default:
00081                 /* Nothing here. */ 00082                 break;
00083         }
00084 }
00085 
00086 exif-utils_8h.html#2c5771b4016b8fc4cd3f93857bfe1d3dExifSShort exif-utils_8h.html#ed1c88bf3ba21a1f45fb1d69f3cec94500087  exif-utils_8c.html#a4e89a6a836b87ad72fa45e13a41076eexif_get_sshort  (const unsigned char *buf, exif-byte-order_8h.html#de4a9c512c9cd4723485181c5679f1d5ExifByteOrder  order)
00088 {
00089         if (!buf) return 0;
00090         switch (order) {
00091         case exif-byte-order_8h.html#de4a9c512c9cd4723485181c5679f1d5bdbfc66d5e97a77e4bea9f5ba9cf2b15EXIF_BYTE_ORDER_MOTOROLA :
00092                 return ((buf[0] << 8) | buf[1]);
00093         case exif-byte-order_8h.html#de4a9c512c9cd4723485181c5679f1d58f11995303c860a57dc560623b0df1f3EXIF_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#23497f35004fb9e65a70b29fd1622a9cExifShort exif-utils_8h.html#4f942f652f0647a1b6fdccd8c930d24c00102  exif-utils_8c.html#28505bc3777648fce6676fc01d74eb40exif_get_short  (const unsigned char *buf, exif-byte-order_8h.html#de4a9c512c9cd4723485181c5679f1d5ExifByteOrder  order)
00103 {
00104         return ( exif-utils_8c.html#a4e89a6a836b87ad72fa45e13a41076eexif_get_sshort  (buf, order) & 0xffff);
00105 }
00106 
00107 void exif-utils_8h.html#a5157a3aa1902138470f9a8d7d29921600108  exif-utils_8c.html#a5157a3aa1902138470f9a8d7d299216exif_set_sshort  (unsigned char *b, exif-byte-order_8h.html#de4a9c512c9cd4723485181c5679f1d5ExifByteOrder  order, exif-utils_8h.html#2c5771b4016b8fc4cd3f93857bfe1d3dExifSShort  mnote-canon-entry_8c.html#085f2f5ed7bf991a182ba0cb960f1c7bvalue )
00109 {
00110         if (!b) return;
00111         switch (order) {
00112         case exif-byte-order_8h.html#de4a9c512c9cd4723485181c5679f1d5bdbfc66d5e97a77e4bea9f5ba9cf2b15EXIF_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#de4a9c512c9cd4723485181c5679f1d58f11995303c860a57dc560623b0df1f3EXIF_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#3c3f4df2af5ea90902c44b23b05e20c300124  exif-utils_8c.html#3c3f4df2af5ea90902c44b23b05e20c3exif_set_short  (unsigned char *b, exif-byte-order_8h.html#de4a9c512c9cd4723485181c5679f1d5ExifByteOrder  order, exif-utils_8h.html#23497f35004fb9e65a70b29fd1622a9cExifShort  mnote-canon-entry_8c.html#085f2f5ed7bf991a182ba0cb960f1c7bvalue )
00125 {
00126         exif-utils_8c.html#a5157a3aa1902138470f9a8d7d299216exif_set_sshort  (b, order, value);
00127 }
00128 
00129 exif-utils_8h.html#afe779ceacc4b89cb135bce740185f17ExifSLong exif-utils_8h.html#00576f53c7355353ec295ddad3661ad200130  exif-utils_8c.html#00576f53c7355353ec295ddad3661ad2exif_get_slong  (const unsigned char *b, exif-byte-order_8h.html#de4a9c512c9cd4723485181c5679f1d5ExifByteOrder  order)
00131 {
00132         if (!b) return 0;
00133         switch (order) {
00134         case exif-byte-order_8h.html#de4a9c512c9cd4723485181c5679f1d5bdbfc66d5e97a77e4bea9f5ba9cf2b15EXIF_BYTE_ORDER_MOTOROLA :
00135                 return ((b[0] << 24) | (b[1] << 16) | (b[2] << 8) | b[3]);
00136         case exif-byte-order_8h.html#de4a9c512c9cd4723485181c5679f1d58f11995303c860a57dc560623b0df1f3EXIF_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#0478d1f9a05e085236824fc1a015896200145  exif-utils_8c.html#0478d1f9a05e085236824fc1a0158962exif_set_slong  (unsigned char *b, exif-byte-order_8h.html#de4a9c512c9cd4723485181c5679f1d5ExifByteOrder  order, exif-utils_8h.html#afe779ceacc4b89cb135bce740185f17ExifSLong  mnote-canon-entry_8c.html#085f2f5ed7bf991a182ba0cb960f1c7bvalue )
00146 {
00147         if (!b) return;
00148         switch (order) {
00149         case exif-byte-order_8h.html#de4a9c512c9cd4723485181c5679f1d5bdbfc66d5e97a77e4bea9f5ba9cf2b15EXIF_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#de4a9c512c9cd4723485181c5679f1d58f11995303c860a57dc560623b0df1f3EXIF_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#1601686195534cc6337c596fb8af54faExifLong exif-utils_8h.html#c1fdeb860c39e2116f34e31e84c2ce9700165  exif-utils_8c.html#c8ce446b600340ccf5f120d8735319f3exif_get_long  (const unsigned char *buf, exif-byte-order_8h.html#de4a9c512c9cd4723485181c5679f1d5ExifByteOrder  order)
00166 {
00167         return ( exif-utils_8c.html#00576f53c7355353ec295ddad3661ad2exif_get_slong  (buf, order) & 0xffffffff);
00168 }
00169 
00170 void exif-utils_8h.html#73d539019fccab7808a97c9501e3154d00171  exif-utils_8c.html#73d539019fccab7808a97c9501e3154dexif_set_long  (unsigned char *b, exif-byte-order_8h.html#de4a9c512c9cd4723485181c5679f1d5ExifByteOrder  order, exif-utils_8h.html#1601686195534cc6337c596fb8af54faExifLong  mnote-canon-entry_8c.html#085f2f5ed7bf991a182ba0cb960f1c7bvalue )
00172 {
00173         exif-utils_8c.html#0478d1f9a05e085236824fc1a0158962exif_set_slong  (b, order, value);
00174 }
00175 
00176 structExifSRational.htmlExifSRational exif-utils_8h.html#28e5d654acc46f101d69e1e1b94f69bd00177  exif-utils_8c.html#4fa17bc36688c952bba26aa81ca4fa63exif_get_srational  (const unsigned char *buf, exif-byte-order_8h.html#de4a9c512c9cd4723485181c5679f1d5ExifByteOrder  order)
00178 {
00179         structExifSRational.htmlExifSRational  r;
00180 
00181         r. structExifSRational.html#3b40097e1e985bcbbc26557e7387d51dnumerator    = buf ? exif-utils_8c.html#00576f53c7355353ec295ddad3661ad2exif_get_slong  (buf, order) : 0;
00182         r. structExifSRational.html#650f320ac105d445be79a1f0da3c3bb0denominator  = buf ? exif-utils_8c.html#00576f53c7355353ec295ddad3661ad2exif_get_slong  (buf + 4, order) : 0;
00183 
00184         return (r);
00185 }
00186 
00187 structExifRational.htmlExifRational exif-utils_8h.html#832e40354658d4751693e41e134a799600188  exif-utils_8c.html#e2e189ba31007fa57643955ec7bd3110exif_get_rational  (const unsigned char *buf, exif-byte-order_8h.html#de4a9c512c9cd4723485181c5679f1d5ExifByteOrder  order)
00189 {
00190         structExifRational.htmlExifRational  r;
00191 
00192         r. structExifRational.html#eb555c81ed222e6d2fc1a8276e54e220numerator    = buf ? exif-utils_8c.html#c8ce446b600340ccf5f120d8735319f3exif_get_long  (buf, order) : 0;
00193         r. structExifRational.html#9ed7ed672889fd57c6862005e07db87cdenominator  = buf ? exif-utils_8c.html#c8ce446b600340ccf5f120d8735319f3exif_get_long  (buf + 4, order) : 0;
00194 
00195         return (r);
00196 }
00197 
00198 void exif-utils_8h.html#fd1685efdf71fb6c0dc24bf83b030bb700199  exif-utils_8c.html#851d763acf065580a0872f56b5aed472exif_set_rational  (unsigned char *buf, exif-byte-order_8h.html#de4a9c512c9cd4723485181c5679f1d5ExifByteOrder  order,
00200                    structExifRational.htmlExifRational  mnote-canon-entry_8c.html#085f2f5ed7bf991a182ba0cb960f1c7bvalue )
00201 {
00202         if (!buf) return;
00203         exif-utils_8c.html#73d539019fccab7808a97c9501e3154dexif_set_long  (buf, order, mnote-canon-entry_8c.html#085f2f5ed7bf991a182ba0cb960f1c7bvalue .numerator);
00204         exif-utils_8c.html#73d539019fccab7808a97c9501e3154dexif_set_long  (buf + 4, order, mnote-canon-entry_8c.html#085f2f5ed7bf991a182ba0cb960f1c7bvalue .denominator);
00205 }
00206 
00207 void exif-utils_8h.html#1d027485e96253efaab171cebfcaf0e100208  exif-utils_8c.html#88d4066528c9acebbc91444a425ea674exif_set_srational  (unsigned char *buf, exif-byte-order_8h.html#de4a9c512c9cd4723485181c5679f1d5ExifByteOrder  order,
00209                     structExifSRational.htmlExifSRational  mnote-canon-entry_8c.html#085f2f5ed7bf991a182ba0cb960f1c7bvalue )
00210 {
00211         if (!buf) return;
00212         exif-utils_8c.html#0478d1f9a05e085236824fc1a0158962exif_set_slong  (buf, order, mnote-canon-entry_8c.html#085f2f5ed7bf991a182ba0cb960f1c7bvalue .numerator);
00213         exif-utils_8c.html#0478d1f9a05e085236824fc1a0158962exif_set_slong  (buf + 4, order, mnote-canon-entry_8c.html#085f2f5ed7bf991a182ba0cb960f1c7bvalue .denominator);
00214 }
Generated on Sun Apr 23 01:22:39 2006 for EXIF library (libexif) Internals by 
http://www.doxygen.org/index.htmldoxygen  1.4.6 