From 5022884e445db78ba314641bcd3903595166ae1e Mon Sep 17 00:00:00 2001 From: "pinkerton%netscape.com" Date: Tue, 6 Oct 1998 03:56:56 +0000 Subject: [PATCH] Added GetImageDimensions() so clients can tell the size of the image. Will fail gracefully if that info is not present. --- cmd/macfe/central/CImageIconMixin.cp | 33 ++++++++++++++++++++++++++++ cmd/macfe/central/CImageIconMixin.h | 4 ++++ 2 files changed, 37 insertions(+) diff --git a/cmd/macfe/central/CImageIconMixin.cp b/cmd/macfe/central/CImageIconMixin.cp index 756727941ca5..338cd863c0b5 100644 --- a/cmd/macfe/central/CImageIconMixin.cp +++ b/cmd/macfe/central/CImageIconMixin.cp @@ -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 - diff --git a/cmd/macfe/central/CImageIconMixin.h b/cmd/macfe/central/CImageIconMixin.h index 33f813fffb4a..957b37511a2f 100644 --- a/cmd/macfe/central/CImageIconMixin.h +++ b/cmd/macfe/central/CImageIconMixin.h @@ -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