summaryrefslogtreecommitdiff
path: root/libopie2/opiemm/opieexif.cpp
Unidiff
Diffstat (limited to 'libopie2/opiemm/opieexif.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiemm/opieexif.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/libopie2/opiemm/opieexif.cpp b/libopie2/opiemm/opieexif.cpp
index de49937..653216c 100644
--- a/libopie2/opiemm/opieexif.cpp
+++ b/libopie2/opiemm/opieexif.cpp
@@ -184,49 +184,49 @@ int ExifData::ReadJpegSections (QFile & infile, ReadMode_t ReadMode)
184 } 184 }
185 185
186 Sections[SectionsRead].Size = itemlen; 186 Sections[SectionsRead].Size = itemlen;
187 187
188 Data = (uchar *)malloc(itemlen+1); // Add 1 to allow sticking a 0 at the end. 188 Data = (uchar *)malloc(itemlen+1); // Add 1 to allow sticking a 0 at the end.
189 Sections[SectionsRead].Data = Data; 189 Sections[SectionsRead].Data = Data;
190 190
191 // Store first two pre-read bytes. 191 // Store first two pre-read bytes.
192 Data[0] = (uchar)lh; 192 Data[0] = (uchar)lh;
193 Data[1] = (uchar)ll; 193 Data[1] = (uchar)ll;
194 194
195 got = infile.readBlock((char*)Data+2, itemlen-2); // Read the whole section. 195 got = infile.readBlock((char*)Data+2, itemlen-2); // Read the whole section.
196 if (( unsigned ) got != itemlen-2){ 196 if (( unsigned ) got != itemlen-2){
197 return false; 197 return false;
198 } 198 }
199 SectionsRead++; 199 SectionsRead++;
200 200
201 switch(marker){ 201 switch(marker){
202 202
203 case M_SOS: // stop before hitting compressed data 203 case M_SOS: // stop before hitting compressed data
204 // If reading entire image is requested, read the rest of the data. 204 // If reading entire image is requested, read the rest of the data.
205 if (ReadMode & READ_IMAGE){ 205 if (ReadMode & READ_IMAGE){
206 unsigned long size; 206 unsigned long size;
207 207
208 size = QMAX( 0ul, infile.size()-infile.at() ); 208 size = infile.size()-infile.at();
209 Data = (uchar *)malloc(size); 209 Data = (uchar *)malloc(size);
210 if (Data == NULL){ 210 if (Data == NULL){
211 return false; 211 return false;
212 } 212 }
213 213
214 got = infile.readBlock((char*)Data, size); 214 got = infile.readBlock((char*)Data, size);
215 if (( unsigned ) got != size){ 215 if (( unsigned ) got != size){
216 return false; 216 return false;
217 } 217 }
218 218
219 Sections[SectionsRead].Data = Data; 219 Sections[SectionsRead].Data = Data;
220 Sections[SectionsRead].Size = size; 220 Sections[SectionsRead].Size = size;
221 Sections[SectionsRead].Type = PSEUDO_IMAGE_MARKER; 221 Sections[SectionsRead].Type = PSEUDO_IMAGE_MARKER;
222 SectionsRead ++; 222 SectionsRead ++;
223 //HaveAll = 1; 223 //HaveAll = 1;
224 } 224 }
225 return true; 225 return true;
226 226
227 case M_EOI: // in case it's a tables-only JPEG stream 227 case M_EOI: // in case it's a tables-only JPEG stream
228 owarn << "No image in jpeg!" << oendl; 228 owarn << "No image in jpeg!" << oendl;
229 return false; 229 return false;
230 230
231 case M_COM: // Comment section 231 case M_COM: // Comment section
232 // pieczy 2002-02-12 232 // pieczy 2002-02-12
@@ -788,49 +788,53 @@ ExifData::ExifData()
788 FocalLength = 0; 788 FocalLength = 0;
789 ExposureTime = 0; 789 ExposureTime = 0;
790 ApertureFNumber = 0; 790 ApertureFNumber = 0;
791 Distance = 0; 791 Distance = 0;
792 CCDWidth = 0; 792 CCDWidth = 0;
793 ExposureBias = 0; 793 ExposureBias = 0;
794 ExposureProgram = 0; 794 ExposureProgram = 0;
795 ISOequivalent = 0; 795 ISOequivalent = 0;
796 CompressionLevel = 0; 796 CompressionLevel = 0;
797 MotorolaOrder = 0; 797 MotorolaOrder = 0;
798} 798}
799 799
800ExifData::~ExifData() 800ExifData::~ExifData()
801{ 801{
802} 802}
803 803
804//-------------------------------------------------------------------------- 804//--------------------------------------------------------------------------
805// process a EXIF jpeg file 805// process a EXIF jpeg file
806//-------------------------------------------------------------------------- 806//--------------------------------------------------------------------------
807bool ExifData::scan(const QString & path) 807bool ExifData::scan(const QString & path)
808{ 808{
809 int ret; 809 int ret;
810 810
811 QFile f(path); 811 QFile f(path);
812 f.open(IO_ReadOnly); 812 if ( !f.open(IO_ReadOnly) ) {
813 owarn << "Unable to open file " << f.name() << " readonly" << oendl;
814 DiscardData();
815 return false;
816 }
813 817
814 // Scan the JPEG headers. 818 // Scan the JPEG headers.
815 ret = ReadJpegSections(f, READ_EXIF); 819 ret = ReadJpegSections(f, READ_EXIF);
816 820
817 if (ret == false){ 821 if (ret == false){
818 owarn << "Not JPEG file!" << oendl; 822 owarn << "Not JPEG file!" << oendl;
819 DiscardData(); 823 DiscardData();
820 f.close(); 824 f.close();
821 return false; 825 return false;
822 } 826 }
823 f.close(); 827 f.close();
824 DiscardData(); 828 DiscardData();
825 829
826 //now make the strings clean, 830 //now make the strings clean,
827 // for exmaple my Casio is a "QV-4000 " 831 // for exmaple my Casio is a "QV-4000 "
828 CameraMake = CameraMake.stripWhiteSpace(); 832 CameraMake = CameraMake.stripWhiteSpace();
829 CameraModel = CameraModel.stripWhiteSpace(); 833 CameraModel = CameraModel.stripWhiteSpace();
830 UserComment = UserComment.stripWhiteSpace(); 834 UserComment = UserComment.stripWhiteSpace();
831 Comment = Comment.stripWhiteSpace(); 835 Comment = Comment.stripWhiteSpace();
832 return true; 836 return true;
833} 837}
834 838
835//-------------------------------------------------------------------------- 839//--------------------------------------------------------------------------
836// Does the embedded thumbnail match the jpeg image? 840// Does the embedded thumbnail match the jpeg image?