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:
pinkerton%netscape.com 1998-10-06 03:56:56 +00:00
Родитель c954c5d637
Коммит 5022884e44
2 изменённых файлов: 37 добавлений и 0 удалений

Просмотреть файл

@ -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