Fixed MSVC compilation (otherwise untested)

v0.27.3
Andreas Huggel 20 years ago
parent 55aebc0686
commit ff718d8de6

@ -127,6 +127,21 @@
<File <File
RelativePath="..\..\src\datasets.cpp"> RelativePath="..\..\src\datasets.cpp">
</File> </File>
<File
RelativePath="..\..\src\error.cpp">
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)/$(InputName)1.obj"/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)/$(InputName)1.obj"/>
</FileConfiguration>
</File>
<File <File
RelativePath="..\..\src\exif.cpp"> RelativePath="..\..\src\exif.cpp">
<FileConfiguration <FileConfiguration
@ -157,6 +172,21 @@
ObjectFile="$(IntDir)/$(InputName)1.obj"/> ObjectFile="$(IntDir)/$(InputName)1.obj"/>
</FileConfiguration> </FileConfiguration>
</File> </File>
<File
RelativePath="..\..\src\futils.cpp">
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)/$(InputName)1.obj"/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)/$(InputName)1.obj"/>
</FileConfiguration>
</File>
<File <File
RelativePath="..\..\src\ifd.cpp"> RelativePath="..\..\src\ifd.cpp">
<FileConfiguration <FileConfiguration
@ -330,6 +360,9 @@
<File <File
RelativePath="..\..\src\fujimn.hpp"> RelativePath="..\..\src\fujimn.hpp">
</File> </File>
<File
RelativePath="..\..\src\futils.hpp">
</File>
<File <File
RelativePath="..\..\src\ifd.hpp"> RelativePath="..\..\src\ifd.hpp">
</File> </File>

@ -42,22 +42,31 @@ struct ImageWrapper
EXIVSIMPLE_API HIMAGE OpenFileImage(const char *file) EXIVSIMPLE_API HIMAGE OpenFileImage(const char *file)
{ {
assert(file); assert(file);
ImageWrapper *imgWrap = new ImageWrapper;
// See if file exists. Sorry for very bad error handling // See if file exists. Sorry for very bad error handling
if (INVALID_FILE_ATTRIBUTES == GetFileAttributes(file)) { if (INVALID_FILE_ATTRIBUTES == GetFileAttributes(file)) {
return 0; return 0;
} }
ImageWrapper *imgWrap = new ImageWrapper;
try {
imgWrap->image = Exiv2::ImageFactory::open(file); imgWrap->image = Exiv2::ImageFactory::open(file);
}
catch(const Exiv2::AnyError&) {
delete imgWrap;
return 0;
}
if (imgWrap->image.get() == 0) { if (imgWrap->image.get() == 0) {
delete imgWrap;
return 0; return 0;
} }
// Load existing metadata // Load existing metadata
if (imgWrap->image->readMetadata()) { try {
imgWrap->image->readMetadata();
}
catch(const Exiv2::AnyError&) {
delete imgWrap; delete imgWrap;
imgWrap = 0; return 0;
} }
return (HIMAGE)imgWrap; return (HIMAGE)imgWrap;
@ -68,15 +77,24 @@ EXIVSIMPLE_API HIMAGE OpenMemImage(const BYTE *data, unsigned int size)
assert(data); assert(data);
ImageWrapper *imgWrap = new ImageWrapper; ImageWrapper *imgWrap = new ImageWrapper;
try {
imgWrap->image = Exiv2::ImageFactory::open(data, size); imgWrap->image = Exiv2::ImageFactory::open(data, size);
}
catch(const Exiv2::AnyError&) {
delete imgWrap;
return 0;
}
if (imgWrap->image.get() == 0) { if (imgWrap->image.get() == 0) {
delete imgWrap;
return 0; return 0;
} }
// Load existing metadata // Load existing metadata
if (imgWrap->image->readMetadata()) { try {
imgWrap->image->readMetadata();
}
catch(const Exiv2::AnyError&) {
delete imgWrap; delete imgWrap;
imgWrap = 0; return 0;
} }
return (HIMAGE)imgWrap; return (HIMAGE)imgWrap;
@ -95,7 +113,13 @@ EXIVSIMPLE_API int SaveImage(HIMAGE img)
{ {
assert(img); assert(img);
ImageWrapper *imgWrap = (ImageWrapper*)img; ImageWrapper *imgWrap = (ImageWrapper*)img;
return imgWrap->image->writeMetadata(); try {
imgWrap->image->writeMetadata();
}
catch(const Exiv2::AnyError&) {
return 1;
}
return 0;
} }
// Note that if you have modified the metadata in any way and want the // Note that if you have modified the metadata in any way and want the
@ -155,7 +179,7 @@ EXIVSIMPLE_API int ReadMeta(HIMAGE img, const char *key, char *buff, int buffsiz
rc = 0; rc = 0;
} }
} }
catch(const Exiv2::Error&) { catch(const Exiv2::AnyError&) {
} }
if (rc) { if (rc) {
@ -170,7 +194,7 @@ EXIVSIMPLE_API int ReadMeta(HIMAGE img, const char *key, char *buff, int buffsiz
rc = 0; rc = 0;
} }
} }
catch(const Exiv2::Error&) { catch(const Exiv2::AnyError&) {
} }
} }
@ -215,7 +239,7 @@ EXIVSIMPLE_API int ModifyMeta(HIMAGE img, const char *key, const char *val, DllT
rc = iptcData.add(iptcKey, value.get()); rc = iptcData.add(iptcKey, value.get());
} }
} }
catch(const Exiv2::Error&) { catch(const Exiv2::AnyError&) {
} }
if (rc) { if (rc) {
@ -240,7 +264,7 @@ EXIVSIMPLE_API int ModifyMeta(HIMAGE img, const char *key, const char *val, DllT
rc = 0; rc = 0;
} }
} }
catch(const Exiv2::Error&) { catch(const Exiv2::AnyError&) {
} }
} }
@ -278,7 +302,7 @@ EXIVSIMPLE_API int AddMeta(HIMAGE img, const char *key, const char *val, DllType
rc = iptcData.add(iptcKey, value.get()); rc = iptcData.add(iptcKey, value.get());
} }
catch(const Exiv2::Error&) { catch(const Exiv2::AnyError&) {
} }
if (rc) { if (rc) {
@ -296,7 +320,7 @@ EXIVSIMPLE_API int AddMeta(HIMAGE img, const char *key, const char *val, DllType
exifData.add(exifKey, value.get()); exifData.add(exifKey, value.get());
rc = 0; rc = 0;
} }
catch(const Exiv2::Error&) { catch(const Exiv2::AnyError&) {
} }
} }
@ -325,7 +349,7 @@ EXIVSIMPLE_API int RemoveMeta(HIMAGE img, const char *key)
rc = 0; rc = 0;
} }
} }
catch(const Exiv2::Error&) { catch(const Exiv2::AnyError&) {
} }
if (rc) { if (rc) {
@ -339,7 +363,7 @@ EXIVSIMPLE_API int RemoveMeta(HIMAGE img, const char *key)
rc = 0; rc = 0;
} }
} }
catch(const Exiv2::Error&) { catch(const Exiv2::AnyError&) {
} }
} }

Loading…
Cancel
Save