add wxImage::SetType() and use it in animation decoders (#9639)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@54932 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -361,6 +361,11 @@ public:
|
|||||||
// Gets the type of image found by LoadFile or specified with SaveFile
|
// Gets the type of image found by LoadFile or specified with SaveFile
|
||||||
wxBitmapType GetType() const;
|
wxBitmapType GetType() const;
|
||||||
|
|
||||||
|
// Set the image type, this is normally only called if the image is being
|
||||||
|
// created from data in the given format but not using LoadFile() (e.g.
|
||||||
|
// wxGIFDecoder uses this)
|
||||||
|
void SetType(wxBitmapType type);
|
||||||
|
|
||||||
// these functions provide fastest access to wxImage data but should be
|
// these functions provide fastest access to wxImage data but should be
|
||||||
// used carefully as no checks are done
|
// used carefully as no checks are done
|
||||||
unsigned char *GetData() const;
|
unsigned char *GetData() const;
|
||||||
|
@@ -1027,6 +1027,25 @@ public:
|
|||||||
unsigned char green,
|
unsigned char green,
|
||||||
unsigned char blue);
|
unsigned char blue);
|
||||||
|
|
||||||
|
/**
|
||||||
|
Set the type of image returned by GetType().
|
||||||
|
|
||||||
|
This method is mostly used internally by the library but can also be
|
||||||
|
called from the user code if the image was created from data in the
|
||||||
|
given bitmap format without using LoadFile() (which would set the type
|
||||||
|
correctly automatically).
|
||||||
|
|
||||||
|
Notice that the image must be created before this function is called.
|
||||||
|
|
||||||
|
@since 2.9.0
|
||||||
|
|
||||||
|
@param type
|
||||||
|
One of bitmap type constants, @c wxBITMAP_TYPE_INVALID is a valid
|
||||||
|
value for it and can be used to reset the bitmap type to default
|
||||||
|
but @c wxBITMAP_TYPE_MAX is not allowed here.
|
||||||
|
*/
|
||||||
|
void SetType(wxBitmapType type);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Returns a resized version of this image without scaling it by adding either a
|
Returns a resized version of this image without scaling it by adding either a
|
||||||
border
|
border
|
||||||
|
@@ -304,6 +304,7 @@ bool wxANIDecoder::Load( wxInputStream& stream )
|
|||||||
if (!sm_handler.DoLoadFile(&image, stream, false /* verbose */, -1))
|
if (!sm_handler.DoLoadFile(&image, stream, false /* verbose */, -1))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
image.SetType(wxBITMAP_TYPE_ANI);
|
||||||
m_images.Add(image);
|
m_images.Add(image);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@@ -122,6 +122,7 @@ bool wxGIFDecoder::ConvertToImage(unsigned int frame, wxImage *image) const
|
|||||||
// create the image
|
// create the image
|
||||||
wxSize sz = GetFrameSize(frame);
|
wxSize sz = GetFrameSize(frame);
|
||||||
image->Create(sz.GetWidth(), sz.GetHeight());
|
image->Create(sz.GetWidth(), sz.GetHeight());
|
||||||
|
image->SetType(wxBITMAP_TYPE_GIF);
|
||||||
|
|
||||||
if (!image->Ok())
|
if (!image->Ok())
|
||||||
return false;
|
return false;
|
||||||
|
@@ -1468,6 +1468,16 @@ wxBitmapType wxImage::GetType() const
|
|||||||
return M_IMGDATA->m_type;
|
return M_IMGDATA->m_type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void wxImage::SetType(wxBitmapType type)
|
||||||
|
{
|
||||||
|
wxCHECK_RET( IsOk(), "must create the image before setting its type");
|
||||||
|
|
||||||
|
// type can be wxBITMAP_TYPE_INVALID to reset the image type to default
|
||||||
|
wxASSERT_MSG( type != wxBITMAP_TYPE_MAX, "invalid bitmap type" );
|
||||||
|
|
||||||
|
M_IMGDATA->m_type = type;
|
||||||
|
}
|
||||||
|
|
||||||
long wxImage::XYToIndex(int x, int y) const
|
long wxImage::XYToIndex(int x, int y) const
|
||||||
{
|
{
|
||||||
if ( Ok() &&
|
if ( Ok() &&
|
||||||
|
Reference in New Issue
Block a user