add support for multiple extensions to wxImage handlers (closes #10570)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@59461 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -375,6 +375,7 @@ All:
|
||||
- Added wxXmlResource::GetResourceNode().
|
||||
- Optimize wxString::Replace() to use an O(N) algorithm (Kuang-che Wu).
|
||||
- Added support of %l format specifier to wxDateTime::ParseFormat().
|
||||
- wxImage handlers can now support multiple extensions (Ivan Krestinin).
|
||||
|
||||
All (Unix):
|
||||
|
||||
|
@@ -108,10 +108,12 @@ public:
|
||||
|
||||
void SetName(const wxString& name) { m_name = name; }
|
||||
void SetExtension(const wxString& ext) { m_extension = ext; }
|
||||
void SetAlExtensions(const wxArrayString& exts) { m_altExtensions = exts; }
|
||||
void SetType(wxBitmapType type) { m_type = type; }
|
||||
void SetMimeType(const wxString& type) { m_mime = type; }
|
||||
const wxString& GetName() const { return m_name; }
|
||||
const wxString& GetExtension() const { return m_extension; }
|
||||
const wxArrayString& GetAltExtensions() const { return m_altExtensions; }
|
||||
wxBitmapType GetType() const { return m_type; }
|
||||
const wxString& GetMimeType() const { return m_mime; }
|
||||
|
||||
@@ -138,6 +140,7 @@ protected:
|
||||
|
||||
wxString m_name;
|
||||
wxString m_extension;
|
||||
wxArrayString m_altExtensions;
|
||||
wxString m_mime;
|
||||
wxBitmapType m_type;
|
||||
|
||||
|
@@ -27,6 +27,8 @@ public:
|
||||
{
|
||||
m_name = wxT("JPEG file");
|
||||
m_extension = wxT("jpg");
|
||||
m_altExtensions.Add(wxT("jpeg"));
|
||||
m_altExtensions.Add(wxT("jpe"));
|
||||
m_type = wxBITMAP_TYPE_JPEG;
|
||||
m_mime = wxT("image/jpeg");
|
||||
}
|
||||
|
@@ -24,6 +24,9 @@ public:
|
||||
{
|
||||
m_name = wxT("PNM file");
|
||||
m_extension = wxT("pnm");
|
||||
m_altExtensions.Add(wxT("ppm"));
|
||||
m_altExtensions.Add(wxT("pgm"));
|
||||
m_altExtensions.Add(wxT("pbm"));
|
||||
m_type = wxBITMAP_TYPE_PNM;
|
||||
m_mime = wxT("image/pnm");
|
||||
}
|
||||
|
@@ -25,6 +25,7 @@ public:
|
||||
{
|
||||
m_name = wxT("TGA file");
|
||||
m_extension = wxT("tga");
|
||||
m_altExtensions.Add(wxT("tpic"));
|
||||
m_type = wxBITMAP_TYPE_TGA;
|
||||
m_mime = wxT("image/tga");
|
||||
}
|
||||
|
@@ -84,10 +84,21 @@ public:
|
||||
virtual ~wxImageHandler();
|
||||
|
||||
/**
|
||||
Gets the file extension associated with this handler.
|
||||
Gets the preferred file extension associated with this handler.
|
||||
|
||||
@see GetAltExtensions()
|
||||
*/
|
||||
const wxString& GetExtension() const;
|
||||
|
||||
/**
|
||||
Returns the other file extensions associated with this handler.
|
||||
|
||||
The preferred extension for this handler is returned by GetExtension().
|
||||
|
||||
@since 2.9.0
|
||||
*/
|
||||
const wxArrayString& GetAltExtensions() const;
|
||||
|
||||
/**
|
||||
If the image file contains more than one image and the image handler is capable
|
||||
of retrieving these individually, this function will return the number of
|
||||
@@ -160,13 +171,27 @@ public:
|
||||
bool verbose = true);
|
||||
|
||||
/**
|
||||
Sets the handler extension.
|
||||
Sets the preferred file extension associated with this handler.
|
||||
|
||||
@param extension
|
||||
Handler extension.
|
||||
File extension without leading dot.
|
||||
|
||||
@see SetAltExtensions()
|
||||
*/
|
||||
void SetExtension(const wxString& extension);
|
||||
|
||||
/**
|
||||
Sets the alternative file extensions associated with this handler.
|
||||
|
||||
@param extensions
|
||||
Array of file extensions.
|
||||
|
||||
@see SetExtension()
|
||||
|
||||
@since 2.9.0
|
||||
*/
|
||||
void SetAltExtensions(const wxArrayString& extensions);
|
||||
|
||||
/**
|
||||
Sets the handler MIME type.
|
||||
|
||||
|
@@ -2438,9 +2438,11 @@ wxImageHandler *wxImage::FindHandler( const wxString& extension, wxBitmapType bi
|
||||
while (node)
|
||||
{
|
||||
wxImageHandler *handler = (wxImageHandler*)node->GetData();
|
||||
if ( (handler->GetExtension().Cmp(extension) == 0) &&
|
||||
( (bitmapType == wxBITMAP_TYPE_ANY) || (handler->GetType() == bitmapType)) )
|
||||
if ((bitmapType == wxBITMAP_TYPE_ANY) || (handler->GetType() == bitmapType))
|
||||
{
|
||||
if (handler->GetExtension() == extension)
|
||||
return handler;
|
||||
if (handler->GetAltExtensions().Index(extension, false) != wxNOT_FOUND)
|
||||
return handler;
|
||||
}
|
||||
node = node->GetNext();
|
||||
@@ -2503,6 +2505,8 @@ wxString wxImage::GetImageExtWildcard()
|
||||
{
|
||||
wxImageHandler* Handler = (wxImageHandler*)Node->GetData();
|
||||
fmts += wxT("*.") + Handler->GetExtension();
|
||||
for (size_t i = 0; i < Handler->GetAltExtensions().size(); i++)
|
||||
fmts += wxT(";*.") + Handler->GetAltExtensions()[i];
|
||||
Node = Node->GetNext();
|
||||
if ( Node ) fmts += wxT(";");
|
||||
}
|
||||
|
@@ -108,6 +108,7 @@ wxTIFFHandler::wxTIFFHandler()
|
||||
{
|
||||
m_name = wxT("TIFF file");
|
||||
m_extension = wxT("tif");
|
||||
m_altExtensions.Add(wxT("tiff"));
|
||||
m_type = wxBITMAP_TYPE_TIF;
|
||||
m_mime = wxT("image/tiff");
|
||||
TIFFSetWarningHandler((TIFFErrorHandler) TIFFwxWarningHandler);
|
||||
|
Reference in New Issue
Block a user