Modify

#3650 closed Bug (Fixed)

Image size off-by-one error with_GDIPlus_ImageResize

Reported by: anonymous Owned by: Jpm
Milestone: Component: Standard UDFs
Version: 3.3.14.0 Severity: None
Keywords: Cc:

Description

The function _GDIPlus_ImageResize creates images that seem to have an off-by-one error regarding the size of the source image placement inside the destination bitmap.

Please see the attached images. The code below was used to up-scale TestImage.png to TestResult.png, and then TestResult.png was viewed in Paint.Net. In the screenshot for Paint.Net you can clearly see the resulting image has a transparent border showing through along the right and bottom edges, while the left and top edges appear as they should. While the resulting image is the correct number of pixels overall, the content inside is slightly small, although not obvious since the missing part is transparent.

This seems to suggest the source image was placed into the destination image with the bottom right coordinates specified one x pixel and one y pixel less than ideal.

Test Code:

#include <GDIPlus.au3>
_GDIPlus_Startup()
Local $hImage = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\TestImage.png")
Local $iWidth = _GDIPlus_ImageGetWidth($hImage)
Local $iHeight = _GDIPlus_ImageGetHeight($hImage)
Local $hBitmap = _GDIPlus_ImageResize( _

$hImage, $iWidth * 4, $iHeight * 4, _
$GDIP_INTERPOLATIONMODE_HIGHQUALITYBICUBIC)

_GDIPlus_ImageSaveToFile($hBitmap, @ScriptDir & "\TestResult.png")
Sleep(500)
_GDIPlus_BitmapDispose($hBitmap)
_GDIPlus_ImageDispose($hImage)
_GDIPlus_Shutdown()

See also (somewhat) related ticket # 3647

Attachments (3)

TestImage.png (2.5 KB ) - added by anonymous on Aug 3, 2018 at 6:08:16 PM.
TestResult.png (53.4 KB ) - added by anonymous on Aug 3, 2018 at 6:08:26 PM.
PaintScreenshot.png (103.6 KB ) - added by anonymous on Aug 3, 2018 at 6:08:40 PM.

Download all attachments as: .zip

Change History (9)

by anonymous, on Aug 3, 2018 at 6:08:16 PM

Attachment: TestImage.png added

by anonymous, on Aug 3, 2018 at 6:08:26 PM

Attachment: TestResult.png added

by anonymous, on Aug 3, 2018 at 6:08:40 PM

Attachment: PaintScreenshot.png added

comment:1 by anonymous, on Aug 6, 2018 at 4:40:55 PM

I made a fix which corrects this issue as well as the issue on ticket #3647. The fix is uploaded to ticket #3647.

comment:2 by anonymous, on Aug 12, 2018 at 4:42:53 PM

Further testing reveals that it's not the bottom and right edges that are missing, but rather the entire image is shifted up and left by one pixel, so it's the top and left edge of the whole image is being clipped.

comment:4 by Jpm, on May 15, 2020 at 4:16:52 PM

Owner: set to Jpm
Status: newassigned

comment:5 by Jpm, on May 16, 2020 at 5:54:02 PM

Resolution: Fixed
Status: assignedclosed

Modify Ticket

Action
as closed The owner will remain Jpm.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.