EnsureMaximumSize and GetThumbnail

The WsImage class wraps a System.Drawing.Bitmap object. It has two methods to control size called EnsureMaximumSize and GetThumbnail. These are the differences:

EnsureMaximumSize transforms the bitmap that is encapsulated in the WsImage object, GetThumbnail returns a bitmap and leaves the encapsulated bitmap unchanged.

EnsureMaximumSize maintains the aspect ratio of the picture and the bitmap object, GetThumbnail returns a rectangular bitmap object with a the original picture drawn onto it. The picture still has maintained aspect radio. You can pass a brush object to control the background, or pass null (Nothing) if you want the background to be transparent.

The similarity is that both EnsureMaximumSize and GetThumbnail only takes one integer parameter to control size. That integer represents the width if the width is larger than the height, otherwise it represents the height.

If you load an image sized 800×600 and pass 700 to the EnsureMaximumSize function, it will return True and the image will be sized 700×525. If you load an image sized 300×400 and pass 350 to the EnsureMaximumSize function, it will return True and the Image will be sized 262×350 pixels. If you load an image sized 300×400 and pass 450 to the EnsureMaximumSize function, it will return False and the image will not be resized.

Download WsImage.

Bjud mig på en kopp kaffe (20:-) som tack för bra innehåll:

Bjud mig på en kopp kaffe (20:-) som tack för bra innehåll!

Comments

Important information: If you have not commented before, your comment will be reviewed before it is published. This means that you will not see it immediately, but I have received it. This is not because I want to filter comments, but because I want to prevent spam and advertising.

Leave a Reply

Your email address will not be published. Required fields are marked *