author | alwin <alwin> | 2004-11-06 02:55:45 (UTC) |
---|---|---|
committer | alwin <alwin> | 2004-11-06 02:55:45 (UTC) |
commit | a93a0ee1fce8b2fb7abac475a97dac8001aed8e0 (patch) (unidiff) | |
tree | 21890174b801d6b14c67740596316847d05ffffe /libopie2 | |
parent | 466245b561abe1514ef37ea978b5958caefdc962 (diff) | |
download | opie-a93a0ee1fce8b2fb7abac475a97dac8001aed8e0.zip opie-a93a0ee1fce8b2fb7abac475a97dac8001aed8e0.tar.gz opie-a93a0ee1fce8b2fb7abac475a97dac8001aed8e0.tar.bz2 |
moved a lot of code from opie-eye_slave into lib
-rw-r--r-- | libopie2/opiemm/opieexif.cpp | 54 | ||||
-rw-r--r-- | libopie2/opiemm/opieexif.h | 7 |
2 files changed, 12 insertions, 49 deletions
diff --git a/libopie2/opiemm/opieexif.cpp b/libopie2/opiemm/opieexif.cpp index 0860ea8..de49937 100644 --- a/libopie2/opiemm/opieexif.cpp +++ b/libopie2/opiemm/opieexif.cpp | |||
@@ -268,25 +268,24 @@ int ExifData::ReadJpegSections (QFile & infile, ReadMode_t ReadMode) | |||
268 | case M_SOF13: | 268 | case M_SOF13: |
269 | case M_SOF14: | 269 | case M_SOF14: |
270 | case M_SOF15: | 270 | case M_SOF15: |
271 | process_SOFn(Data, marker); | 271 | process_SOFn(Data, marker); |
272 | default: | 272 | default: |
273 | break; | 273 | break; |
274 | break; | 274 | break; |
275 | } | 275 | } |
276 | } | 276 | } |
277 | return true; | 277 | return true; |
278 | } | 278 | } |
279 | 279 | ||
280 | |||
281 | //-------------------------------------------------------------------------- | 280 | //-------------------------------------------------------------------------- |
282 | // Discard read data. | 281 | // Discard read data. |
283 | //-------------------------------------------------------------------------- | 282 | //-------------------------------------------------------------------------- |
284 | void ExifData::DiscardData(void) | 283 | void ExifData::DiscardData(void) |
285 | { | 284 | { |
286 | for (int a=0; a < SectionsRead; a++) | 285 | for (int a=0; a < SectionsRead; a++) |
287 | free(Sections[a].Data); | 286 | free(Sections[a].Data); |
288 | SectionsRead = 0; | 287 | SectionsRead = 0; |
289 | } | 288 | } |
290 | 289 | ||
291 | //-------------------------------------------------------------------------- | 290 | //-------------------------------------------------------------------------- |
292 | // Convert a 16 bit unsigned value from file's native byte order | 291 | // Convert a 16 bit unsigned value from file's native byte order |
@@ -1000,91 +999,48 @@ static QImage rotate_270_all( const QImage& img ) { | |||
1000 | } | 999 | } |
1001 | } | 1000 | } |
1002 | return dest; | 1001 | return dest; |
1003 | } | 1002 | } |
1004 | 1003 | ||
1005 | static QImage rotate_270( const QImage& img ) { | 1004 | static QImage rotate_270( const QImage& img ) { |
1006 | if ( img.depth() > 8 ) | 1005 | if ( img.depth() > 8 ) |
1007 | return rotate_270_all( img ); | 1006 | return rotate_270_all( img ); |
1008 | else | 1007 | else |
1009 | return rotate_270_8( img ); | 1008 | return rotate_270_8( img ); |
1010 | } | 1009 | } |
1011 | 1010 | ||
1012 | 1011 | QString ExifData::color_mode_to_string( bool b ) { | |
1013 | static QString color_mode_to_string( bool b ) { | ||
1014 | return b ? QObject::tr( "Colormode: Color\n" ) : QObject::tr( "Colormode: Black and white\n" ); | 1012 | return b ? QObject::tr( "Colormode: Color\n" ) : QObject::tr( "Colormode: Black and white\n" ); |
1015 | } | 1013 | } |
1016 | 1014 | ||
1017 | static QString compression_to_string( int level ) { | 1015 | QString ExifData::compression_to_string( int level ) { |
1018 | QString str; | 1016 | QString str; |
1019 | switch( level ) { | 1017 | switch( level ) { |
1020 | case 1: | 1018 | case 1: |
1021 | str = QObject::tr( "Basic" ); | 1019 | str = QObject::tr( "Basic" ); |
1022 | break; | 1020 | break; |
1023 | case 2: | 1021 | case 2: |
1024 | str = QObject::tr( "Normal" ); | 1022 | str = QObject::tr( "Normal" ); |
1025 | break; | 1023 | break; |
1026 | case 4: | 1024 | case 4: |
1027 | str = QObject::tr( "Fine" ); | 1025 | str = QObject::tr( "Fine" ); |
1028 | break; | 1026 | break; |
1029 | default: | 1027 | default: |
1030 | str = QObject::tr( "Unknown" ); | 1028 | str = QObject::tr( "Unknown" ); |
1031 | 1029 | ||
1032 | } | 1030 | } |
1033 | return QObject::tr("Quality: %1\n").arg(str); | 1031 | return QObject::tr("Quality: %1\n").arg(str); |
1034 | } | 1032 | } |
1035 | 1033 | ||
1036 | 1034 | QString ExifData::white_balance_string( int i ) { | |
1037 | static QDateTime parseDateTime( const QString& string ) | ||
1038 | { | ||
1039 | QDateTime dt; | ||
1040 | if ( string.length() != 19 ) | ||
1041 | return dt; | ||
1042 | |||
1043 | QString year = string.left( 4 ); | ||
1044 | QString month = string.mid( 5, 2 ); | ||
1045 | QString day = string.mid( 8, 2 ); | ||
1046 | QString hour = string.mid( 11, 2 ); | ||
1047 | QString minute = string.mid( 14, 2 ); | ||
1048 | QString seconds = string.mid( 18, 2 ); | ||
1049 | |||
1050 | bool ok; | ||
1051 | bool allOk = true; | ||
1052 | int y = year.toInt( &ok ); | ||
1053 | allOk &= ok; | ||
1054 | |||
1055 | int mo = month.toInt( &ok ); | ||
1056 | allOk &= ok; | ||
1057 | |||
1058 | int d = day.toInt( &ok ); | ||
1059 | allOk &= ok; | ||
1060 | |||
1061 | int h = hour.toInt( &ok ); | ||
1062 | allOk &= ok; | ||
1063 | |||
1064 | int mi = minute.toInt( &ok ); | ||
1065 | allOk &= ok; | ||
1066 | |||
1067 | int s = seconds.toInt( &ok ); | ||
1068 | allOk &= ok; | ||
1069 | |||
1070 | if ( allOk ) { | ||
1071 | dt.setDate( QDate( y, mo, d ) ); | ||
1072 | dt.setTime( QTime( h, mi, s ) ); | ||
1073 | } | ||
1074 | |||
1075 | return dt; | ||
1076 | } | ||
1077 | |||
1078 | static QString white_balance_string( int i ) { | ||
1079 | QString balance; | 1035 | QString balance; |
1080 | switch ( i ) { | 1036 | switch ( i ) { |
1081 | case 0: | 1037 | case 0: |
1082 | balance = QObject::tr( "Unknown" ); | 1038 | balance = QObject::tr( "Unknown" ); |
1083 | break; | 1039 | break; |
1084 | case 1: | 1040 | case 1: |
1085 | balance = QObject::tr( "Daylight" ); | 1041 | balance = QObject::tr( "Daylight" ); |
1086 | break; | 1042 | break; |
1087 | case 2: | 1043 | case 2: |
1088 | balance = QObject::tr( "Fluorescent" ); | 1044 | balance = QObject::tr( "Fluorescent" ); |
1089 | break; | 1045 | break; |
1090 | case 3: | 1046 | case 3: |
@@ -1110,25 +1066,25 @@ static QString white_balance_string( int i ) { | |||
1110 | break; | 1066 | break; |
1111 | case 255: | 1067 | case 255: |
1112 | balance = QObject::tr( "Other" ); | 1068 | balance = QObject::tr( "Other" ); |
1113 | break; | 1069 | break; |
1114 | default: | 1070 | default: |
1115 | balance = QObject::tr( "Unknown" ); | 1071 | balance = QObject::tr( "Unknown" ); |
1116 | } | 1072 | } |
1117 | return QObject::tr( "White Balance: %1\n" ).arg( balance ); | 1073 | return QObject::tr( "White Balance: %1\n" ).arg( balance ); |
1118 | 1074 | ||
1119 | } | 1075 | } |
1120 | 1076 | ||
1121 | 1077 | ||
1122 | static QString metering_mode( int i) { | 1078 | QString ExifData::metering_mode( int i) { |
1123 | QString meter; | 1079 | QString meter; |
1124 | switch( i ) { | 1080 | switch( i ) { |
1125 | case 0: | 1081 | case 0: |
1126 | meter = QObject::tr( "Unknown" ); | 1082 | meter = QObject::tr( "Unknown" ); |
1127 | break; | 1083 | break; |
1128 | case 1: | 1084 | case 1: |
1129 | meter = QObject::tr( "Average" ); | 1085 | meter = QObject::tr( "Average" ); |
1130 | break; | 1086 | break; |
1131 | case 2: | 1087 | case 2: |
1132 | meter = QObject::tr( "Center weighted average" ); | 1088 | meter = QObject::tr( "Center weighted average" ); |
1133 | break; | 1089 | break; |
1134 | case 3: | 1090 | case 3: |
@@ -1145,25 +1101,25 @@ static QString metering_mode( int i) { | |||
1145 | break; | 1101 | break; |
1146 | case 255: | 1102 | case 255: |
1147 | meter = QObject::tr( "Other" ); | 1103 | meter = QObject::tr( "Other" ); |
1148 | break; | 1104 | break; |
1149 | default: | 1105 | default: |
1150 | meter = QObject::tr( "Unknown" ); | 1106 | meter = QObject::tr( "Unknown" ); |
1151 | } | 1107 | } |
1152 | 1108 | ||
1153 | return QObject::tr( "Metering Mode: %1\n" ).arg( meter ); | 1109 | return QObject::tr( "Metering Mode: %1\n" ).arg( meter ); |
1154 | } | 1110 | } |
1155 | 1111 | ||
1156 | 1112 | ||
1157 | static QString exposure_program( int i ) { | 1113 | QString ExifData::exposure_program( int i ) { |
1158 | QString exp; | 1114 | QString exp; |
1159 | switch( i ) { | 1115 | switch( i ) { |
1160 | case 0: | 1116 | case 0: |
1161 | exp = QObject::tr( "Not defined" ); | 1117 | exp = QObject::tr( "Not defined" ); |
1162 | break; | 1118 | break; |
1163 | case 1: | 1119 | case 1: |
1164 | exp = QObject::tr( "Manual" ); | 1120 | exp = QObject::tr( "Manual" ); |
1165 | break; | 1121 | break; |
1166 | case 2: | 1122 | case 2: |
1167 | exp = QObject::tr( "Normal progam" ); | 1123 | exp = QObject::tr( "Normal progam" ); |
1168 | break; | 1124 | break; |
1169 | case 3: | 1125 | case 3: |
diff --git a/libopie2/opiemm/opieexif.h b/libopie2/opiemm/opieexif.h index efaed71..fb06bf8 100644 --- a/libopie2/opiemm/opieexif.h +++ b/libopie2/opiemm/opieexif.h | |||
@@ -123,17 +123,24 @@ public: | |||
123 | int getWhitebalance() { return Whitebalance; } | 123 | int getWhitebalance() { return Whitebalance; } |
124 | int getMeteringMode() { return MeteringMode; } | 124 | int getMeteringMode() { return MeteringMode; } |
125 | float getCCDWidth() { return CCDWidth; } | 125 | float getCCDWidth() { return CCDWidth; } |
126 | float getExposureBias() { return ExposureBias; } | 126 | float getExposureBias() { return ExposureBias; } |
127 | int getExposureProgram() { return ExposureProgram; } | 127 | int getExposureProgram() { return ExposureProgram; } |
128 | int getISOequivalent() { return ISOequivalent; } | 128 | int getISOequivalent() { return ISOequivalent; } |
129 | int getCompressionLevel() { return CompressionLevel; } | 129 | int getCompressionLevel() { return CompressionLevel; } |
130 | QString getUserComment() { return UserComment; } | 130 | QString getUserComment() { return UserComment; } |
131 | QString getComment() { return Comment; } | 131 | QString getComment() { return Comment; } |
132 | QImage getThumbnail(); | 132 | QImage getThumbnail(); |
133 | bool isThumbnailSane(); | 133 | bool isThumbnailSane(); |
134 | bool isNullThumbnail() { return !isThumbnailSane(); } | 134 | bool isNullThumbnail() { return !isThumbnailSane(); } |
135 | |||
136 | // some helpers | ||
137 | static QString color_mode_to_string( bool b ); | ||
138 | static QString compression_to_string( int level ); | ||
139 | static QString white_balance_string( int i ); | ||
140 | static QString metering_mode( int i); | ||
141 | static QString exposure_program( int i ); | ||
135 | }; | 142 | }; |
136 | 143 | ||
137 | } | 144 | } |
138 | } | 145 | } |
139 | #endif | 146 | #endif |