main.html
Main Page
|
classes.html
Alphabetical List
|
annotated.html
Data Structures
|
dirs.html
Directories
|
files.html
File List
|
functions.html
Data Fields
|
globals.html
Globals
dir_000000.html
libexif
exif-utils.c
exif-utils_8c.html
Go 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.html
libexif/exif-utils.h
>
00024
00025
void
exif-utils_8h.html#a21
00026
exif-utils_8c.html#a0
exif_array_set_byte_order
(
exif-format_8h.html#a14
ExifFormat
f,
unsigned
char
*b,
unsigned
int
n,
00027
exif-byte-order_8h.html#a3
ExifByteOrder
o_orig,
exif-byte-order_8h.html#a3
ExifByteOrder
o_new)
00028 {
00029
unsigned
int
j;
00030
unsigned
int
fs =
exif-format_8c.html#a5
exif_format_get_size
(f);
00031
exif-utils_8h.html#a4
ExifShort
s;
00032
exif-utils_8h.html#a5
ExifSShort
ss;
00033
exif-utils_8h.html#a6
ExifLong
l;
00034
exif-utils_8h.html#a8
ExifSLong
sl;
00035
structExifRational.html
ExifRational
r;
00036
structExifSRational.html
ExifSRational
sr;
00037
00038
if
(!b || !n || !fs)
return
;
00039
00040
switch
(f) {
00041
case
exif-format_8h.html#a14a2
EXIF_FORMAT_SHORT
:
00042
for
(j = 0; j < n; j++) {
00043                         s =
exif-utils_8c.html#a2
exif_get_short
(b + j * fs, o_orig);
00044
exif-utils_8c.html#a4
exif_set_short
(b + j * fs, o_new, s);
00045                 }
00046
break
;
00047
case
exif-format_8h.html#a14a7
EXIF_FORMAT_SSHORT
:
00048
for
(j = 0; j < n; j++) {
00049                         ss =
exif-utils_8c.html#a1
exif_get_sshort
(b + j * fs, o_orig);
00050
exif-utils_8c.html#a3
exif_set_sshort
(b + j * fs, o_new, ss);
00051                 }
00052
break
;
00053
case
exif-format_8h.html#a14a3
EXIF_FORMAT_LONG
:
00054
for
(j = 0; j < n; j++) {
00055                         l =
exif-utils_8c.html#a7
exif_get_long
(b + j * fs, o_orig);
00056
exif-utils_8c.html#a8
exif_set_long
(b + j * fs, o_new, l);
00057                 }
00058
break
;
00059
case
exif-format_8h.html#a14a4
EXIF_FORMAT_RATIONAL
:
00060
for
(j = 0; j < n; j++) {
00061                         r =
exif-utils_8c.html#a10
exif_get_rational
(b + j * fs, o_orig);
00062
exif-utils_8c.html#a11
exif_set_rational
(b + j * fs, o_new, r);
00063                 }
00064
break
;
00065
case
exif-format_8h.html#a14a8
EXIF_FORMAT_SLONG
:
00066
for
(j = 0; j < n; j++) {
00067                         sl =
exif-utils_8c.html#a5
exif_get_slong
(b + j * fs, o_orig);
00068
exif-utils_8c.html#a6
exif_set_slong
(b + j * fs, o_new, sl);
00069                 }
00070
break
;
00071
case
exif-format_8h.html#a14a9
EXIF_FORMAT_SRATIONAL
:
00072
for
(j = 0; j < n; j++) {
00073                         sr =
exif-utils_8c.html#a9
exif_get_srational
(b + j * fs, o_orig);
00074
exif-utils_8c.html#a12
exif_set_srational
(b + j * fs, o_new, sr);
00075                 }
00076
break
;
00077
case
exif-format_8h.html#a14a6
EXIF_FORMAT_UNDEFINED
:
00078
case
exif-format_8h.html#a14a0
EXIF_FORMAT_BYTE
:
00079
case
exif-format_8h.html#a14a1
EXIF_FORMAT_ASCII
:
00080
default
:
00081
/* Nothing here. */
00082
break
;
00083         }
00084 }
00085
00086
exif-utils_8h.html#a5
ExifSShort
exif-utils_8h.html#a10
00087
exif-utils_8c.html#a1
exif_get_sshort
(
const
unsigned
char
*buf,
exif-byte-order_8h.html#a3
ExifByteOrder
order)
00088 {
00089
if
(!buf)
return
0;
00090
switch
(order) {
00091
case
exif-byte-order_8h.html#a3a0
EXIF_BYTE_ORDER_MOTOROLA
:
00092
return
((buf[0] << 8) | buf[1]);
00093
case
exif-byte-order_8h.html#a3a1
EXIF_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#a4
ExifShort
exif-utils_8h.html#a9
00102
exif-utils_8c.html#a2
exif_get_short
(
const
unsigned
char
*buf,
exif-byte-order_8h.html#a3
ExifByteOrder
order)
00103 {
00104
return
(
exif-utils_8c.html#a1
exif_get_sshort
(buf, order) & 0xffff);
00105 }
00106
00107
void
exif-utils_8h.html#a16
00108
exif-utils_8c.html#a3
exif_set_sshort
(
unsigned
char
*b,
exif-byte-order_8h.html#a3
ExifByteOrder
order,
exif-utils_8h.html#a5
ExifSShort
mnote-canon-entry_8c.html#a5
value
)
00109 {
00110
if
(!b)
return
;
00111
switch
(order) {
00112
case
exif-byte-order_8h.html#a3a0
EXIF_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#a3a1
EXIF_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#a15
00124
exif-utils_8c.html#a4
exif_set_short
(
unsigned
char
*b,
exif-byte-order_8h.html#a3
ExifByteOrder
order,
exif-utils_8h.html#a4
ExifShort
mnote-canon-entry_8c.html#a5
value
)
00125 {
00126
exif-utils_8c.html#a3
exif_set_sshort
(b, order, value);
00127 }
00128
00129
exif-utils_8h.html#a8
ExifSLong
exif-utils_8h.html#a12
00130
exif-utils_8c.html#a5
exif_get_slong
(
const
unsigned
char
*b,
exif-byte-order_8h.html#a3
ExifByteOrder
order)
00131 {
00132
if
(!b)
return
0;
00133
switch
(order) {
00134
case
exif-byte-order_8h.html#a3a0
EXIF_BYTE_ORDER_MOTOROLA
:
00135
return
((b[0] << 24) | (b[1] << 16) | (b[2] << 8) | b[3]);
00136
case
exif-byte-order_8h.html#a3a1
EXIF_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#a18
00145
exif-utils_8c.html#a6
exif_set_slong
(
unsigned
char
*b,
exif-byte-order_8h.html#a3
ExifByteOrder
order,
exif-utils_8h.html#a8
ExifSLong
mnote-canon-entry_8c.html#a5
value
)
00146 {
00147
if
(!b)
return
;
00148
switch
(order) {
00149
case
exif-byte-order_8h.html#a3a0
EXIF_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#a3a1
EXIF_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#a6
ExifLong
exif-utils_8h.html#a11
00165
exif-utils_8c.html#a7
exif_get_long
(
const
unsigned
char
*buf,
exif-byte-order_8h.html#a3
ExifByteOrder
order)
00166 {
00167
return
(
exif-utils_8c.html#a5
exif_get_slong
(buf, order) & 0xffffffff);
00168 }
00169
00170
void
exif-utils_8h.html#a17
00171
exif-utils_8c.html#a8
exif_set_long
(
unsigned
char
*b,
exif-byte-order_8h.html#a3
ExifByteOrder
order,
exif-utils_8h.html#a6
ExifLong
mnote-canon-entry_8c.html#a5
value
)
00172 {
00173
exif-utils_8c.html#a6
exif_set_slong
(b, order, value);
00174 }
00175
00176
structExifSRational.html
ExifSRational
exif-utils_8h.html#a14
00177
exif-utils_8c.html#a9
exif_get_srational
(
const
unsigned
char
*buf,
exif-byte-order_8h.html#a3
ExifByteOrder
order)
00178 {
00179
structExifSRational.html
ExifSRational
r;
00180
00181         r.
structExifSRational.html#o0
numerator
= buf ?
exif-utils_8c.html#a5
exif_get_slong
(buf, order) : 0;
00182         r.
structExifSRational.html#o1
denominator
= buf ?
exif-utils_8c.html#a5
exif_get_slong
(buf + 4, order) : 0;
00183
00184
return
(r);
00185 }
00186
00187
structExifRational.html
ExifRational
exif-utils_8h.html#a13
00188
exif-utils_8c.html#a10
exif_get_rational
(
const
unsigned
char
*buf,
exif-byte-order_8h.html#a3
ExifByteOrder
order)
00189 {
00190
structExifRational.html
ExifRational
r;
00191
00192         r.
structExifRational.html#o0
numerator
= buf ?
exif-utils_8c.html#a7
exif_get_long
(buf, order) : 0;
00193         r.
structExifRational.html#o1
denominator
= buf ?
exif-utils_8c.html#a7
exif_get_long
(buf + 4, order) : 0;
00194
00195
return
(r);
00196 }
00197
00198
void
exif-utils_8h.html#a19
00199
exif-utils_8c.html#a11
exif_set_rational
(
unsigned
char
*buf,
exif-byte-order_8h.html#a3
ExifByteOrder
order,
00200
structExifRational.html
ExifRational
mnote-canon-entry_8c.html#a5
value
)
00201 {
00202
if
(!buf)
return
;
00203
exif-utils_8c.html#a8
exif_set_long
(buf, order, value.
structExifRational.html#o0
numerator
);
00204
exif-utils_8c.html#a8
exif_set_long
(buf + 4, order, value.
structExifRational.html#o1
denominator
);
00205 }
00206
00207
void
exif-utils_8h.html#a20
00208
exif-utils_8c.html#a12
exif_set_srational
(
unsigned
char
*buf,
exif-byte-order_8h.html#a3
ExifByteOrder
order,
00209
structExifSRational.html
ExifSRational
mnote-canon-entry_8c.html#a5
value
)
00210 {
00211
if
(!buf)
return
;
00212
exif-utils_8c.html#a6
exif_set_slong
(buf, order, value.
structExifSRational.html#o0
numerator
);
00213
exif-utils_8c.html#a6
exif_set_slong
(buf + 4, order, value.
structExifSRational.html#o1
denominator
);
00214 }
Generated on Fri Sep 9 16:28:11 2005 for EXIF library (libexif) Internals by
http://www.doxygen.org/index.html
doxygen
1.4.4
