DNU in GdiplusImage>>thumbnailWithExtent: for GdiplusImage created from IStream

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

DNU in GdiplusImage>>thumbnailWithExtent: for GdiplusImage created from IStream

Yar Hwee Boon-3
Hi all,

Under Gdiplus 5.0.9, executing the code below in a workspace raises a DNU  
for GdiplusImageFromIStreamInitializer>>absoluteFilename.

=====================
file := GdiplusImage fromFile: 'Resources/Dolphin1.bmp' usingLocator:  
FileLocator installRelative.
byteArray := file asByteArray: 'image/bmp'.
image := GdiplusImage fromByteArray: byteArray.
thumbnail := image thumbnailScaledBy: 1.
=====================

This is due to the line "initializer: (self class fromFile: self filename)  
initializer;" in GdiplusImage>>thumbnailWithExtent: which assumes that the  
image is created from a GdiplusImageFromFileInitializer.

=====================
GdiplusImage>>thumbnailWithExtent: aPoint
        | gpImage status |
        gpImage := ExternalHandle new.
        (status := GdiplusLibrary default
                                GdipGetImageThumbnail: self asParameter
                                thumbWidth: aPoint x
                                thumbHeight: aPoint y
                                thumbImage: gpImage
                                pfnCallback: nil
                                callbackData: nil) = Ok
                ifFalse: [^GdiplusError signal: 'Error in GdipGetImageThumbnail' with:  
status].
        ^(self class fromOwnedHandle: gpImage)
                initializer: (self class fromFile: self filename) initializer;
                yourself
=====================

I just left "initializer" as nil (see below) as I don't really find a use  
for it in my case. Can anyone (Louis, etc?) provide an appropriate fix?

=====================
GdiplusImage>>thumbnailWithExtent: aPoint
        | gpImage status |
        gpImage := ExternalHandle new.
        (status := GdiplusLibrary default
                                GdipGetImageThumbnail: self asParameter
                                thumbWidth: aPoint x
                                thumbHeight: aPoint y
                                thumbImage: gpImage
                                pfnCallback: nil
                                callbackData: nil) = Ok
                ifFalse: [^GdiplusError signal: 'Error in GdipGetImageThumbnail' with:  
status].
        ^self class fromOwnedHandle: gpImage
=====================

--
Regards
Hwee Boon
MotionObj


Reply | Threaded
Open this post in threaded view
|

Re: DNU in GdiplusImage>>thumbnailWithExtent: for GdiplusImage created from IStream

Louis Sumberg-2
Hwee Boon,

Thanks for doing the investigation and documenting it so well in your post.
For now, I think the fix is to add an #absoluteFilename accessor method to
the initializer that returns nil, i.e.,

GdiplusImageFromFileInitializer>>absoluteFilename
    ^nil

I should look at it closer and add some unit tests, but I'm in the midst of
a move, so hopefully this does it for now.  I'd rather add the accessor
method in the initializer than make the change to the GdiplusImage method
since the latter change might be disruptive to existing things.

-- Louis