зеркало из https://github.com/mozilla/gecko-dev.git
Added GetImageDimensions() so clients can tell the size of the image. Will fail gracefully if that info is not present.
This commit is contained in:
Родитель
c954c5d637
Коммит
5022884e44
|
@ -137,6 +137,39 @@ CImageIconMixin :: SetImageURL ( const string & inNewURL )
|
|||
} // SetImageURL
|
||||
|
||||
|
||||
//
|
||||
// GetImageDimensions
|
||||
//
|
||||
// If the image has been loaded, this returns true and the dimensions of the
|
||||
// image in |outDimensions|
|
||||
//
|
||||
bool
|
||||
CImageIconMixin :: GetImageDimensions ( SDimension16 & outDimensions )
|
||||
{
|
||||
bool imagePresent = false;
|
||||
|
||||
try {
|
||||
if ( gImageCache().RequestIcon(mURL, this) == CImageCache::kDataPresent ) {
|
||||
|
||||
DrawingState state;
|
||||
state.copyMode = srcCopy;
|
||||
gImageCache().FetchImageData ( mURL, &state.pixmap, &state.mask );
|
||||
|
||||
outDimensions.width = state.pixmap->pixmap.bounds.right;
|
||||
outDimensions.height = state.pixmap->pixmap.bounds.bottom;
|
||||
|
||||
imagePresent = true;
|
||||
}
|
||||
}
|
||||
catch ( invalid_argument & ia ) {
|
||||
DebugStr("\pData requested for something not in cache");
|
||||
}
|
||||
|
||||
return imagePresent;
|
||||
|
||||
} // GetImageDimensions
|
||||
|
||||
|
||||
#pragma mark -
|
||||
|
||||
|
||||
|
|
|
@ -57,6 +57,10 @@ public:
|
|||
void DrawImage ( const Point & inTopLeft, IconTransformType inTransform,
|
||||
Uint32 inWidth, Uint32 inHeight ) const;
|
||||
|
||||
// If the image has been loaded, this returns true and the dimensions of the
|
||||
// image in |outDimensions|
|
||||
bool GetImageDimensions ( SDimension16 & outDimensions ) ;
|
||||
|
||||
protected:
|
||||
|
||||
// catch the message that the image is ready to draw
|
||||
|
|
Загрузка…
Ссылка в новой задаче