Opened 16 years ago

Closed 16 years ago

#422 closed Bug (Fixed)

_GDIPlus_GraphicsSetSmoothingMode Failure

Reported by: WeaponX Owned by: Gary
Milestone: Component: AutoIt
Version: Severity: None
Keywords: Cc:

Description (last modified by Valik)

Calling _GDIPlus_GraphicsSetSmoothingMode($hGraphics, 2) returns FALSE and sets @ERROR.

The function actually changes $iSmooth into the SmoothingMode enum value:

In the following test you can see the only values that perform smoothing are 2 and 4:

#include <GuiConstantsEx.au3>
#include <GDIPlus.au3>

Const $GuiHeight = 200, $GuiWidth = 500
Global $CenterX = $GuiWidth / 2, $CenterY = $GuiHeight / 2

$hGUI = GUICreate("Anti-Aliasing", $GuiWidth, $GuiHeight)

;Initialize GDI+

$hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)

;Create pen
$hPen = _GDIPlus_PenCreate(0xFF000000, 2,2)
_GDIPlus_PenSetWidth($hPen, 1)

$LastX = 0

typedef enum {
    SmoothingModeInvalid = QualityModeInvalid,
    SmoothingModeDefault = QualityModeDefault,
    SmoothingModeHighSpeed = QualityModeLow,
    SmoothingModeHighQuality = QualityModeHigh,
    SmoothingModeAntiAlias = SmoothingModeAntiAlias8x4,
} SmoothingMode;

For $Z = 0 to 7
	$result = _GDIPlus_GraphicsSetSmoothingMode2($hGraphic, $Z)
	ConsoleWrite("@ERROR: " & @ERROR & " @EXTENDED: " & @EXTENDED & " RESULT: " & $result & @CRLF)
	For $X = 1 to 10
		_GDIPlus_GraphicsDrawLine($hGraphic, $LastX, 0, $LastX+20, $GuiHeight, $hPen)
		$LastX += 3
	$LastX += 3
	;Reset smoothing mode
	_GDIPlus_GraphicsSetSmoothingMode2($hGraphic, 0)



Func _GDIPlus_GraphicsSetSmoothingMode2($hGraphics, $iMode)
	Local $aResult

	$aResult = DllCall($ghGDIPDll, "int", "GdipSetSmoothingMode", "hwnd", $hGraphics, "int", $iMode)
	If @error Then Return SetError(@error, @extended, False)
	Return SetError($aResult[0], 0, $aResult[0] = 0)
EndFunc   ;==>_GDIPlus_GraphicsSetSmoothingMode

Attachments (0)

Change History (3)

comment:1 Changed 16 years ago by Valik

  • Description modified (diff)

comment:2 Changed 16 years ago by WeaponX

Just for added clarification, the code I posted draws 8 sets of diagonal lines. The values tested were from 0-7. Attempting to use dllcall with GdipSetSmoothingMode throws an error for values greater than 4.

The function _GDIPlus_GraphicsSetSmoothingMode2 is the same as in GDI.au3 except it passes $iMode directly instead of converting it with Switch...EndSwitch.

comment:3 Changed 16 years ago by Gary

  • Milestone set to
  • Owner set to Gary
  • Resolution set to Fixed
  • Status changed from new to closed

Fixed in version:

Guidelines for posting comments:

  • You cannot re-open a ticket but you may still leave a comment if you have additional information to add.
  • In-depth discussions should take place on the forum.

For more information see the full version of the ticket guidelines here.

Add Comment

Modify Ticket

as closed The owner will remain Gary.

E-mail address and user name can be saved in the Preferences.

Note: See TracTickets for help on using tickets.