Jump to content

GDIP.au3


Authenticity
 Share

Recommended Posts

I'd like to list the following resources which I've found very useful, most of this is from there:

GDI+ Classes

José Roca's GDI+ reference and forum

developpez, a french site but with in-depth explanation.

And a warm thanks to Sjaak Priester for his wonderful ColorMatrix tool and source which the ColorMatrix funtions are built on.

I've forgot ;), thanks to Paul Campbell (PaulIA) for the great UDF, Malkey, UEZ, trancexx, monoceres, and everybody else for posting generous GDI+ examples.

This UDF is just a wrapper around GDIPlus.au3 to include the rest of the exports.

Notes about error handling:

There exist two additional status variables to catch function status or error codes. $GDIP_STATUS contains the return value from the function and it's meaning can be examined in GDIPlusConstants.au3 for a short description. A few functions may also set $GDIP_ERROR variable to a value explained in the function description. This variable should be contained in conditional code only when it's set by the GDIPlus functions as $GDIP_ERROR is never cleared, only set on error.

Currently:

_GDIPlus_BitmapCreateFromFileICM

_GDIPlus_BitmapCreateFromGdiDib

_GDIPlus_BitmapCreateFromHICON

_GDIPlus_BitmapCreateFromResource

_GDIPlus_BitmapCreateFromScan0

_GDIPlus_BitmapCreateFromStream

_GDIPlus_BitmapCreateFromStreamICM

_GDIPlus_BitmapGetPixel

_GDIPlus_BitmapSetPixel

_GDIPlus_BitmapSetResolution

_GDIPlus_HICONCreateFromBitmap

_GDIPlus_CachedBitmapCreate

_GDIPlus_CachedBitmapDispose

_GDIPlus_ColorMatrixCreate

_GDIPlus_ColorMatrixCreateGrayScale

_GDIPlus_ColorMatrixCreateNegative

_GDIPlus_ColorMatrixCreateSaturation

_GDIPlus_ColorMatrixCreateScale

_GDIPlus_ColorMatrixCreateTranslate

_GDIPlus_ColorMatrixInitHue

_GDIPlus_ColorMatrixMultiply

_GDIPlus_ColorMatrixRotateBlue

_GDIPlus_ColorMatrixRotateColor

_GDIPlus_ColorMatrixRotateGreen

_GDIPlus_ColorMatrixRotateHue

_GDIPlus_ColorMatrixRotateRed

_GDIPlus_ColorMatrixScale

_GDIPlus_ColorMatrixSetSaturation

_GDIPlus_ColorMatrixShearBlue

_GDIPlus_ColorMatrixShearColor

_GDIPlus_ColorMatrixShearGreen

_GDIPlus_ColorMatrixShearRed

_GDIPlus_ColorMatrixTranslate

_GDIPlus_ColorMatrixTransformLuminance

_GDIPlus_CustomLineCapClone

_GDIPlus_CustomLineCapCreate

_GDIPlus_CustomLineCapGetBaseCap

_GDIPlus_CustomLineCapGetBaseInset

_GDIPlus_CustomLineCapGetStrokeCaps

_GDIPlus_CustomLineCapGetStrokeJoin

_GDIPlus_CustomLineCapGetType

_GDIPlus_CustomLineCapGetWidthScale

_GDIPlus_CustomLineCapSetBaseCap

_GDIPlus_CustomLineCapSetBaseInset

_GDIPlus_CustomLineCapSetStrokeCaps

_GDIPlus_CustomLineCapSetStrokeJoin

_GDIPlus_CustomLineCapSetWidthScale

_GDIPlus_FontClone

_GDIPlus_FontCollectionCreate

_GDIPlus_FontCollectionGetFamilyCount

_GDIPlus_FontCollectionGetFamilyList

_GDIPlus_FontCreateFromDC

_GDIPlus_FontCreateFromLogfont

_GDIPlus_FontGetFamily

_GDIPlus_FontGetHeight

_GDIPlus_FontGetHeightGivenDPI

_GDIPlus_FontGetLogFont

_GDIPlus_FontGetSize

_GDIPlus_FontGetStyle

_GDIPlus_FontGetUnit

_GDIPlus_PrivateCollectionAddFontFile

_GDIPlus_PrivateCollectionAddMemoryFont

_GDIPlus_PrivateCollectionCreate

_GDIPlus_PrivateFontCollectionDispose

_GDIPlus_FontFamilyClone

_GDIPlus_FontFamilyCreate2

_GDIPlus_FontFamilyCreateGenericMonospace

_GDIPlus_FontFamilyCreateGenericSansSerif

_GDIPlus_FontFamilyCreateGenericSerif

_GDIPlus_FontFamilyGetCellAscent

_GDIPlus_FontFamilyGetCellDescent

_GDIPlus_FontFamilyGetEmHeight

_GDIPlus_FontFamilyGetFamilyName

_GDIPlus_FontFamilyGetLineSpacing

_GDIPlus_FontFamilyIsStyleAvailable

_GDIPlus_CreateHalftonePalette

_GDIPlus_GraphicsBeginContainer

_GDIPlus_GraphicsBeginContainer2

_GDIPlus_GraphicsComment

_GDIPlus_GraphicsCreateFromHDC2

_GDIPlus_GraphicsCreateFromHWNDICM

_GDIPlus_GraphicsDrawBeziers

_GDIPlus_GraphicsDrawCachedBitmap

_GDIPlus_GraphicsDrawClosedCurve2

_GDIPlus_GraphicsDrawCurve2

_GDIPlus_GraphicsDrawCurve3

_GDIPlus_GraphicsDrawImagePointRect

_GDIPlus_GraphicsDrawImagePointsRect

_GDIPlus_GraphicsDrawImageRectRectIA

_GDIPlus_GraphicsDrawLines

_GDIPlus_GraphicsDrawPath

_GDIPlus_GraphicsDrawRectangles

_GDIPlus_GraphicsEndContainer

_GDIPlus_GraphicsFillClosedCurve2

_GDIPlus_GraphicsFillPath

_GDIPlus_GraphicsFillPolygon2

_GDIPlus_GraphicsFillRectangles

_GDIPlus_GraphicsFillRegion

_GDIPlus_GraphicsFlush

_GDIPlus_GraphicsGetClip

_GDIPlus_GraphicsGetClipBounds

_GDIPlus_GraphicsGetCompositingMode

_GDIPlus_GraphicsGetCompositingQuality

_GDIPlus_GraphicsGetDpiX

_GDIPlus_GraphicsGetDpiY

_GDIPlus_GraphicsGetInterpolationMode

_GDIPlus_GraphicsGetNearestColor

_GDIPlus_GraphicsGetPageScale

_GDIPlus_GraphicsGetPageUnit

_GDIPlus_GraphicsGetPixelOffsetMode

_GDIPlus_GraphicsGetRenderingOrigin

_GDIPlus_GraphicsGetTextContrast

_GDIPlus_GraphicsGetTextRenderingHint

_GDIPlus_GraphicsGetTransform

_GDIPlus_GraphicsGetVisibleClipBounds

_GDIPlus_GraphicsIsClipEmpty

_GDIPlus_GraphicsIsVisibleClipEmpty

_GDIPlus_GraphicsIsVisiblePoint

_GDIPlus_GraphicsIsVisibleRect

_GDIPlus_GraphicsMultiplyTransform

_GDIPlus_GraphicsResetClip

_GDIPlus_GraphicsResetPageTransform

_GDIPlus_GraphicsResetTransform

_GDIPlus_GraphicsRestore

_GDIPlus_GraphicsRotateTransform

_GDIPlus_GraphicsSave

_GDIPlus_GraphicsScaleTransform

_GDIPlus_GraphicsSetClipGraphics

_GDIPlus_GraphicsSetClipHrgn

_GDIPlus_GraphicsSetClipPath

_GDIPlus_GraphicsSetClipRect

_GDIPlus_GraphicsSetClipRegion

_GDIPlus_GraphicsSetCompositingMode

_GDIPlus_GraphicsSetCompositingQuality

_GDIPlus_GraphicsSetInterpolationMode

_GDIPlus_GraphicsSetPageScale

_GDIPlus_GraphicsSetPageUnit

_GDIPlus_GraphicsSetPixelOffsetMode

_GDIPlus_GraphicsSetRenderingOrigin

_GDIPlus_GraphicsSetTextContrast

_GDIPlus_GraphicsSetTextRenderingHint

_GDIPlus_GraphicsTransformPoints

_GDIPlus_GraphicsTransformPointsI

_GDIPlus_GraphicsTranslateClip

_GDIPlus_GraphicsTranslateTransform

_GDIPlus_StreamCreateOnFile

_GDIPlus_MetafileCreateFromEmf

_GDIPlus_MetafileCreateFromFile

_GDIPlus_MetafileCreateFromStream

_GDIPlus_MetafileCreateFromWmf

_GDIPlus_MetafileCreateFromWmfFile

_GDIPlus_MetafileCreateHENMETAFILEFromMetafile

_GDIPlus_MetafileEmfToWmfBits

_GDIPlus_MetafileEnumerateDestPoint

_GDIPlus_MetafileEnumerateDestPoints

_GDIPlus_MetafileEnumerateDestRect

_GDIPlus_MetafileEnumerateSrcRectDestPoint

_GDIPlus_MetafileEnumerateSrcRectDestPoints

_GDIPlus_MetafileEnumerateSrcRectDestRect

_GDIPlus_MetafileGetDownLevelRasterizationLimit

_GDIPlus_MetafileHeaderFromEmf

_GDIPlus_MetafileHeaderFromFile

_GDIPlus_MetafileHeaderFromMetafile

_GDIPlus_MetafileHeaderFromStream

_GDIPlus_MetafileHeaderFromWmf

_GDIPlus_MetafilePlayRecord

_GDIPlus_MetafileRecord

_GDIPlus_MetafileRecordFileName

_GDIPlus_MetafileRecordStream

_GDIPlus_MetafileSetDownLevelRasterizationLimit

_GDIPlus_PathAddArc

_GDIPlus_PathAddBezier

_GDIPlus_PathAddBeziers

_GDIPlus_PathAddClosedCurve

_GDIPlus_PathAddClosedCurves

_GDIPlus_PathAddCurve

_GDIPlus_PathAddCurves

_GDIPlus_PathAddCurvesSubset

_GDIPlus_PathAddEllipse

_GDIPlus_PathAddLine

_GDIPlus_PathAddLines

_GDIPlus_PathAddPath

_GDIPlus_PathAddPie

_GDIPlus_PathAddPolygon

_GDIPlus_PathAddRectangle

_GDIPlus_PathAddRectangles

_GDIPlus_PathAddString

_GDIPlus_PathClearMarkers

_GDIPlus_PathClone

_GDIPlus_PathCloseFigure

_GDIPlus_PathCloseFigures

_GDIPlus_PathCreate

_GDIPlus_PathCreate2

_GDIPlus_PathDispose

_GDIPlus_PathFlatten

_GDIPlus_PathGetData

_GDIPlus_PathGetFillMode

_GDIPlus_PathGetLastPoint

_GDIPlus_PathGetPointCount

_GDIPlus_PathGetPoints

_GDIPlus_PathGetPointsI

_GDIPlus_PathGetTypes

_GDIPlus_PathGetWorldBounds

_GDIPlus_PathIsOutlineVisiblePoint

_GDIPlus_PathIsVisiblePoint

_GDIPlus_PathReset

_GDIPlus_PathReverse

_GDIPlus_PathSetFillMode

_GDIPlus_PathSetMarker

_GDIPlus_PathStartFigure

_GDIPlus_PathTransform

_GDIPlus_PathWarp

_GDIPlus_PathWiden

_GDIPlus_PathWindingModeOutline

_GDIPlus_PathIterCopyData

_GDIPlus_PathIterCreate

_GDIPlus_PathIterDispose

_GDIPlus_PathIterEnumerate

_GDIPlus_PathIterGetCount

_GDIPlus_PathIterGetSubpathCount

_GDIPlus_PathIterHasCurve

_GDIPlus_PathIterIsValid

_GDIPlus_PathIterNextMarker

_GDIPlus_PathIterNextMarkerPath

_GDIPlus_PathIterNextPathType

_GDIPlus_PathIterNextSubpath

_GDIPlus_PathIterNextSubpathPath

_GDIPlus_PathIterRewind

_GDIPlus_HatchBrushCreate

_GDIPlus_HatchBrushGetBackgroundColor

_GDIPlus_HatchBrushGetForegroundColor

_GDIPlus_HatchBrushGetStyle

_GDIPlus_ImageClone

_GDIPlus_ImageForceValidation

_GDIPlus_ImageGetAllPropertyItems

_GDIPlus_ImageGetBounds

_GDIPlus_ImageGetDimension

_GDIPlus_ImageGetFrameCount

_GDIPlus_ImageGetFrameDimensionsCount

_GDIPlus_ImageGetFrameDimensionsList

_GDIPlus_ImageGetPalette

_GDIPlus_ImageGetPaletteSize

_GDIPlus_ImageGetPropertyCount

_GDIPlus_ImageGetPropertyIdList

_GDIPlus_ImageGetPropertyItem

_GDIPlus_ImageGetPropertyItemSize

_GDIPlus_ImageGetPropertySize

_GDIPlus_ImageGetThumbnail

_GDIPlus_ImageLoadFromFileICM

_GDIPlus_ImageLoadFromStream

_GDIPlus_ImageLoadFromStreamICM

_GDIPlus_ImageRemovePropertyItem

_GDIPlus_ImageRotateFlip

_GDIPlus_ImageSaveAdd

_GDIPlus_ImageSaveAddImage

_GDIPlus_ImageSaveToStream

_GDIPlus_ImageSelectActiveFrame

_GDIPlus_ImageSetPalette

_GDIPlus_ImageSetPropertyItem

_GDIPlus_ImageAttributesClone

_GDIPlus_ImageAttributesCreate

_GDIPlus_ImageAttributesDispose

_GDIPlus_ImageAttributesGetAdjustedPalette

_GDIPlus_ImageAttributesReset

_GDIPlus_ImageAttributesSetColorKeys

_GDIPlus_ImageAttributesSetColorMatrix

_GDIPlus_ImageAttributesSetGamma

_GDIPlus_ImageAttributesSetNoOp

_GDIPlus_ImageAttributesSetOutputChannel

_GDIPlus_ImageAttributesSetOutputChannelColorProfile

_GDIPlus_ImageAttributesSetRemapTable

_GDIPlus_ImageAttributesSetThreshold

_GDIPlus_ImageAttributesSetToIdentity

_GDIPlus_ImageAttributesSetWrapMode

_GDIPlus_LineBrushCreate

_GDIPlus_LineBrushCreateFromRect

_GDIPlus_LineBrushCreateFromRectWithAngle

_GDIPlus_LineBrushGetBlend

_GDIPlus_LineBrushGetBlendCount

_GDIPlus_LineBrushGetColors

_GDIPlus_LineBrushGetGammaCorrection

_GDIPlus_LineBrushGetPresetBlend

_GDIPlus_LineBrushGetPresetBlendCount

_GDIPlus_LineBrushGetRect

_GDIPlus_LineBrushGetTransform

_GDIPlus_LineBrushGetWrapMode

_GDIPlus_LineBrushMultiplyTransform

_GDIPlus_LineBrushResetTransform

_GDIPlus_LineBrushRotateTransform

_GDIPlus_LineBrushScaleTransform

_GDIPlus_LineBrushSetBlend

_GDIPlus_LineBrushSetColors

_GDIPlus_LineBrushSetGammaCorrection

_GDIPlus_LineBrushSetLinearBlend

_GDIPlus_LineBrushSetPresetBlend

_GDIPlus_LineBrushSetSigmaBlend

_GDIPlus_LineBrushSetTransform

_GDIPlus_LineBrushSetWrapMode

_GDIPlus_LineBrushTranslateTransform

_GDIPlus_MatrixClone

_GDIPlus_MatrixCreate2

_GDIPlus_MatrixCreate3

_GDIPlus_MatrixGetElements

_GDIPlus_MatrixInvert

_GDIPlus_MatrixIsEqual

_GDIPlus_MatrixIsIdentity

_GDIPlus_MatrixIsInvertible

_GDIPlus_MatrixMultiply

_GDIPlus_MatrixSetElements

_GDIPlus_MatrixShear

_GDIPlus_MatrixTransformPoints

_GDIPlus_MatrixTransformPointsI

_GDIPlus_MatrixVectorTransformPoints

_GDIPlus_MatrixVectorTransformPointsI

_GDIPlus_PathBrushCreate

_GDIPlus_PathBrushCreateFromPath

_GDIPlus_PathBrushGetBlend

_GDIPlus_PathBrushGetBlendCount

_GDIPlus_PathBrushGetCenterColor

_GDIPlus_PathBrushGetCenterPoint

_GDIPlus_PathBrushGetCenterPointI

_GDIPlus_PathBrushGetFocusScales

_GDIPlus_PathBrushGetGammaCorrection

_GDIPlus_PathBrushGetPointCount

_GDIPlus_PathBrushGetPresetBlend

_GDIPlus_PathBrushGetPresetBlendCount

_GDIPlus_PathBrushGetRect

_GDIPlus_PathBrushGetSurroundColorCount

_GDIPlus_PathBrushGetSurroundColorsWithCount

_GDIPlus_PathBrushGetTransform

_GDIPlus_PathBrushGetWrapMode

_GDIPlus_PathBrushMultiplyTransform

_GDIPlus_PathBrushResetTransform

_GDIPlus_PathBrushRotateTransform

_GDIPlus_PathBrushScaleTransform

_GDIPlus_PathBrushSetBlend

_GDIPlus_PathBrushSetCenterColor

_GDIPlus_PathBrushSetCenterPoint

_GDIPlus_PathBrushSetFocusScales

_GDIPlus_PathBrushSetGammaCorrection

_GDIPlus_PathBrushSetLinearBlend

_GDIPlus_PathBrushSetPresetBlend

_GDIPlus_PathBrushSetSigmaBlend

_GDIPlus_PathBrushSetSurroundColorsWithCount

_GDIPlus_PathBrushSetTransform

_GDIPlus_PathBrushSetWrapMode

_GDIPlus_PathBrushTranslateTransform

_GDIPlus_PenClone

_GDIPlus_PenCreate2

_GDIPlus_PenGetBrushFill

_GDIPlus_PenGetCompoundArray

_GDIPlus_PenGetCompoundCount

_GDIPlus_PenGetCustomStartCap

_GDIPlus_PenGetDashArray

_GDIPlus_PenGetDashCount

_GDIPlus_PenGetDashOffset

_GDIPlus_PenGetFillType

_GDIPlus_PenGetLineJoin

_GDIPlus_PenGetMiterLimit

_GDIPlus_PenGetStartCap

_GDIPlus_PenGetTransform

_GDIPlus_PenGetUnit

_GDIPlus_PenMultiplyTransform

_GDIPlus_PenResetTransform

_GDIPlus_PenRotateTransform

_GDIPlus_PenScaleTransform

_GDIPlus_PenSetBrushFill

_GDIPlus_PenSetCompoundArray

_GDIPlus_PenSetCustomStartCap

_GDIPlus_PenSetDashArray

_GDIPlus_PenSetDashOffset

_GDIPlus_PenSetLineCap

_GDIPlus_PenSetLineJoin

_GDIPlus_PenSetMiterLimit

_GDIPlus_PenSetStartCap

_GDIPlus_PenSetTransform

_GDIPlus_PenSetUnit

_GDIPlus_PenTranslateTransform

_GDIPlus_RegionClone

_GDIPlus_RegionCombinePath

_GDIPlus_RegionCombineRect

_GDIPlus_RegionCombineRegion

_GDIPlus_RegionCreate

_GDIPlus_RegionCreateFromHrgn

_GDIPlus_RegionCreateFromPath

_GDIPlus_RegionCreateFromRect

_GDIPlus_RegionCreateFromRgnData

_GDIPlus_RegionDispose

_GDIPlus_RegionGetBounds

_GDIPlus_RegionGetData

_GDIPlus_RegionGetDataSize

_GDIPlus_RegionGetHRgn

_GDIPlus_RegionGetScans

_GDIPlus_RegionGetScansCount

_GDIPlus_RegionIsEmpty

_GDIPlus_RegionIsEqual

_GDIPlus_RegionIsInfinite

_GDIPlus_RegionIsVisiblePoint

_GDIPlus_RegionIsVisibleRect

_GDIPlus_RegionSetEmpty

_GDIPlus_RegionSetInfinite

_GDIPlus_RegionTransform

_GDIPlus_RegionTranslate

_GDIPlus_BrushGetFillColor

_GDIPlus_BrushSetFillColor

_GDIPlus_StringFormatClone

_GDIPlus_StringFormatCreateDefault

_GDIPlus_StringFormatCreateTypographic

_GDIPlus_StringFormatGetAlign

_GDIPlus_StringFormatGetDigitSubstitution

_GDIPlus_StringFormatGetFlags

_GDIPlus_StringFormatGetHotkeyPrefix

_GDIPlus_StringFormatGetLineAlign

_GDIPlus_StringFormatGetMeasurableCharacterRangeCount

_GDIPlus_StringFormatGetTabStopCount

_GDIPlus_StringFormatGetTabStops

_GDIPlus_StringFormatGetTrimming

_GDIPlus_StringFormatSetDigitSubstitution

_GDIPlus_StringFormatSetFlags

_GDIPlus_StringFormatSetHotkeyPrefix

_GDIPlus_StringFormatSetLineAlign

_GDIPlus_StringFormatSetMeasurableCharacterRanges

_GDIPlus_StringFormatSetTabStops

_GDIPlus_StringFormatSetTrimming

_GDIPlus_GraphicsDrawDriverString

_GDIPlus_GraphicsMeasureCharacterRanges

_GDIPlus_GraphicsMeasureDriverString

_GDIPlus_TextureCreate

_GDIPlus_TextureCreate2

_GDIPlus_TextureCreateIA

_GDIPlus_TextureGetImage

_GDIPlus_TextureGetTransform

_GDIPlus_TextureGetWrapMode

_GDIPlus_TextureMultiplyTransform

_GDIPlus_TextureResetTransform

_GDIPlus_TextureRotateTransform

_GDIPlus_TextureScaleTransform

_GDIPlus_TextureSetTransform

_GDIPlus_TextureSetWrapMode

_GDIPlus_TextureTranslateTransform

I've included a few examples, mostly the useless ones but it's because it's the hardest part to sit and write meaningful examples, even for the simplest functions. :)

Edit: Special thanks to all the contributes. B)

History:

Update 27.12.2010:
 - Removed various constants declared by other UDFs.

Update 11.12.2010:
 - Removed _WinAPI_* functions from UDF (thanks ProgAndy).
   Examples that rely on these functions define them.

Update 03.08.2010:
 - Added _GDIPlus_FontFamilyCreate2. (thanks Yashied)
 - Fixed _GDIPlus_PrivateFontCollectionDispose. (thanks Yashied)
 - Updated user call-tips and functions highlight.

Update 13.07.2010:
 - Added a few examples that are somewhat related to GDI+.
 - Fixed some of the image frame functions.

Update 06.06.2010:
 - Fixed _GDIPlus_PathAddRectangles function.

Update 03.06.2010:
 - Fixed GDIP.au3, now compatible with AutoIt v3.3.6.1.
 - Fixed _GDIPlus_PathWarp function. Thank you eukalyptus for the catch.

Update 12.12.2009:
 - Fixed several examples and their counterpart functions, as required.

Update 11.12.2009:
 - Added a few more examples to the ImageAttributes object functions.
 - Fixed _GDIPlus_ImageAttributesSetNoOp function description.
 - Fixed _GDIPlus_BitmapCreateFromStreamICM function description and call tip.

Update 06.12.2009:
 - Added a few ColorMatrix manipulation functions, see top of the page for acknowledges.
 - Added a few more examples to the ImageAttribute object.

Update 04.12.2009:
 - Added a few more examples for InstalledCollection, Graphics, GraphicsContainer.
 - Fixed _GDIPlus_GraphicsDrawRectangles and _GDIPlus_GraphicsFillRectangles functions
 - Fixed a few examples that used some old functions syntax

Update 03.12.2009:
 - Added function descriptions.
 - A few function definitions have been redefined to be consistent with return and parameters values.
 - No additional examples at the moment.

GDIP.7z

Edited by Authenticity
Link to comment
Share on other sites

Great extensions of GDI+ library!

Maybe now dreams come true... :)

Thanks for sharing!

UEZ

PS: 5* from me for your efforts

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

Nice. When you add descriptions it would be much nicer.

There is one thing I don't understand. It's:

If @error Then Return SetError(@error, @extended, 0)

I can see how could that be useful when you look to the future or whatever. But only with eyes closed.

That technique shouldn't be considered as a final solution.

Even though it seems smart, usually it's adding more confusion when debugging than it should. If the function is complex one (more than one DllCall) it's almost impossible to determine what's failing.

For example you have function _GDIPlus_FontCollectionGetFamilyList().

Let's say it fails for some reason. You check @error and it's 3. You check @extended and it's 0.

What failed?

Wouldn't be much better to do something like this?

If @error Then Return SetError($iRelativeErrorPosition, @error, 0)

Where $iRelativeErrorPosition would be number that would uniquely identify position of error inside the function.

Will wait for description of functions before rating it fairly :) .

♡♡♡

.

eMyvnE

Link to comment
Share on other sites

PLEASE !! Can you give me an working example of using _GDIPlus_TextureRotateTransform or _GDIPlus_ImageRotateFlip function with .png image. Im now working on some project and using normal matrix transform is horrible (it is rotating entire graphics content [i mean the size of entire GC] not only my image, and calculating new position of image is some nightmare), Thank You ! :)

BTW those funcitons are really really great ! I hope that the can be implemented in some ne comming BETA some days ;)

Edited by Uriziel01
Link to comment
Share on other sites

Nice. When you add descriptions it would be much nicer.

There is one thing I don't understand. It's:

If @error Then Return SetError(@error, @extended, 0)

...

Let's say it fails for some reason. You check @error and it's 3. You check @extended and it's 0.

What failed?

Wouldn't be much better to do something like this?

If @error Then Return SetError($iRelativeErrorPosition, @error, 0)

Where $iRelativeErrorPosition would be number that would uniquely identify position of error inside the function.

...

Thanks for the tips. You're absolutely right and I know that, you can see somewhere in the functions definitions something like:

If $iData = 0 The Return SetError(1, 1, 0)

..or returning -1 but it'll not be the final solution. Yes I'm a bit lazy in my nature but when things need to be done, they'll be done sometime.

The most problematic thing about it is to find a uniform way not to make the Remarks and Return sections redundant with if that then that, anyway I'm now working on the function decoration and rewriting the code as necessary. Funny thing, at the end the decorations are going to triple the file size from 3k lines to 9k+ lines :) Just as my first post, it wasn't and isn't complete. Thanks again for the suggestions.

P.S. I'm not expecting a starting scripter to walk through each and every error possibility or even use error handling at all so if the user is using it, the user probably knows what may be wrong but this is not an excuse to write a bad function.

PLEASE !! Can you give me an working example of using _GDIPlus_TextureRotateTransform or _GDIPlus_ImageRotateFlip function with .png image. Im now working on some project and using normal matrix transform is horrible (it is rotating entire graphics content [i mean the size of entire GC] not only my image, and calculating new position of image is some nightmare), Thank You ! ;)

BTW those funcitons are really really great ! I hope that the can be implemented in some ne comming BETA some days B)

Link. Search José Roca's forum, you'll find examples for almost any function exported via GDI+, most of the examples, eventually, will be taken from there. Read the PowerBASIC code, it's closer to AutoIt than the C++ one.

Edit: You! B) Now I need to manage 4 different states... Is $GDIP_STATUS and $GDIP_ERROR in conjunction with @error and @extended sounds sufficient?. $GDIP_STATUS is set to the return value (if DllCall didn't fail) of the function when applicable, $GDIP_ERROR will be set to 0 always and to an increasing integer that specifies the nested GDI+ function that failed. Comments?

Edited by Authenticity
Link to comment
Share on other sites

Here an example with _GDIPlus_HatchBrushCreate() function (53 fill patterns):

Nothing special but imho worth mentioning.

;Coded by UEZ 2009.12.06
#include <GDIplus.au3>
Opt("GUIOnEventMode", 1)

_GDIPlus_Startup()
Global $width = @DesktopWidth * 0.75
Global $height = @DesktopHeight * 0.75

Global $hwnd = GUICreate("GDI+: Filled Brushes by UEZ", $width, $height, -1, -1, Default)
GUISetOnEvent(-3, "_Exit")
GUISetState()

Global $graphics = _GDIPlus_GraphicsCreateFromHWND($hwnd)
_GDIPlus_GraphicsSetSmoothingMode($graphics, 4)

Global $brush[53]
For $i = 0 To UBound($brush) - 1
    $brush[$i] = _GDIPlus_HatchBrushCreate($i, 0xFF0000FF, 0xFFFFFFFF)
Next

$dx = Int($width / 8)
$dy = Int($height / 7)

_GDIPlus_GraphicsClear($graphics, 0xFF000000)

$k = 0
For $i = 0 To $height -1 Step $dy
    For $j = 0 To $width - 1 Step $dx
        If $k <= UBound($brush) -1 Then _GDIPlus_GraphicsFillEllipse($graphics, $j, $i, $dx, $dy, $brush[$k])
        $k += 1
    Next
Next

While Sleep(150)
WEnd


Func _Exit()
    For $i = 0 To UBound($brush) - 1
        _GDIPlus_BrushDispose($brush[$i])
    Next
    _GDIPlus_GraphicsDispose($graphics)
    _GDIPlus_Shutdown()
    Exit
EndFunc

Func _GDIPlus_HatchBrushCreate($iHatchStyle = 0, $iARGBForeground = 0xFFFFFFFF, $iARGBBackground = 0xFFFFFFFF)
    Local $aResult = DllCall($ghGDIPDll, "uint", "GdipCreateHatchBrush", "int", $iHatchStyle, "uint", $iARGBForeground, "uint", $iARGBBackground, "int*", 0)

    If @error Then Return SetError(@error, @extended, 0)
    Return SetError($aResult[0], 0, $aResult[4])
EndFunc ;==>_GDIPlus_HatchBrushCreate

Thanks to Authenticity for the additional GDI+ function. Currently I'm searching within the functions for some nice functions...

Have a nice Santa Claus

UEZ

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

w00t :) Thanks for the example, better than what I could come up with, for sure.

Here is a little translated tool original written by Sjaak Priester. I've just translated it (not so good) but it's still good to show the ColorMatrix functions meaning:

#include <Constants.au3>
#include <GDIP.au3>
#include <GUIConstantsEx.au3>
#include <ScrollBarConstants.au3>
#include <GUIToolbar.au3>
#include <WindowsConstants.au3>

Opt('MustDeclareVars', 1)

If Not IsDeclared("SB_ENDSCROLL") Then Global Const $SB_ENDSCROLL = 8

Global $hToolbar
Global Enum $idOpen = 0x0400, $idSave
Global $aLables[5] = ["Contrast", "Brightness", "Saturation", "Hue", "Gamma"]
; Slider, hSlider, Label, Min, Max, Default, Factor, Precision, PreviousVal
Global $aSliders[5][9] = _
   [[0, 0, 0, 4, 80, 20, 0.05, 2, -1], _
    [0, 0, 0, -20, 20, 0, 0.05, 2, -1], _
    [0, 0, 0, 0, 60, 20, 0.05, 2, -1], _
    [0, 0, 0, -45, 45, 0, 4, 0, -1], _
    [0, 0, 0, 4, 80, 20, 0.05, 2, -1]]
    
Global $hGraphics, $hImage, $hBackImage, $hImageContext, $hIA, $tPreHue, $tPostHue, $aImageSize, $sImage, $iPicWidth, $iPicHeight, $fChange
Global $sImageFormats = "All Picture Files (*.bmp;*.gif;*.jpg;*.jpeg;*.jpe;*.jfif;*.tif;*.tiff;*.png;*.exif;*.wmf;*.emf)"

_GDIPlus_Startup()
_Main()
_GDIPlus_Shutdown()

Func _Main()
    Local $hGUI, $BtnReset, $BtnBlackWhite, $iGUIWidth, $iGUIHeight, $iLeft, $iTop, $iI, $aSize
    
    $iGUIWidth = @DesktopWidth*0.75
    $iGUIHeight = @DesktopHeight*0.75
    
    If $iGUIWidth < 900 Then $iGUIWidth = 900
    If $iGUIHeight < 700 Then $iGUIHeight = 700

    $hGUI = GUICreate("Image tool", $iGUIWidth, $iGUIHeight)
    $hToolbar = _GUICtrlToolbar_Create ($hGUI)
    $aSize = _GUICtrlToolbar_GetMaxSize ($hToolbar)
    
    
    $iPicWidth = $iGUIWidth-250
    $iPicHeight = $iGUIHeight - $aSize[1] - 30

    GUICtrlCreateLabel("", 10, $aSize[1] + 20, $iPicWidth, $iPicHeight, -1, $WS_EX_CLIENTEDGE)
    $hGraphics = _GDIPlus_GraphicsCreateFromHWND(GUICtrlGetHandle(-1))
    $hIA = _GDIPlus_ImageAttributesCreate()
    
    _GDIPlus_GraphicsSetInterpolationMode($hGraphics, 7)
    
    $iLeft = $iGUIWidth - 230
    $iTop = $aSize[1]+20
    
    For $iI = 0 To UBound($aSliders)-1
        GUICtrlCreateLabel($aLables[$iI], $iLeft, $iI*60+$iTop)
        $aSliders[$iI][0] = GUICtrlCreateSlider($iLeft, $iI*60+$iTop+20, 150, 20)
        $aSliders[$iI][1] = GUICtrlGetHandle(-1)
        $aSliders[$iI][2] = GUICtrlCreateLabel("", $iLeft+160, $iI*60+$iTop+20, 40, 25)
        GUICtrlSetLimit($aSliders[$iI][0], $aSliders[$iI][4], $aSliders[$iI][3])
    Next
    
    _Reset()

    $BtnReset = GUICtrlCreateButton("Reset", $iLeft+125, $iI*60+$iTop, 70, 25)
    $BtnBlackWhite = GUICtrlCreateButton("Black&&White", $iLeft+50, $iI*60+$iTop, 70, 25)
    
    _GUICtrlToolbar_AddBitmap ($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR)
    _GUICtrlToolbar_AddButton ($hToolbar, $idOpen, $STD_FILEOPEN)
    _GUICtrlToolbar_AddButton ($hToolbar, $idSave, $STD_FILESAVE)

    GUIRegisterMsg($WM_NOTIFY, "_WM_NOTIFY")
    GUIRegisterMsg($WM_HSCROLL, "_WM_HSCROLL")
    GUISetState()
    
    While 1
        Switch GUIGetMsg()
            Case $BtnReset
                _Reset()
                
            Case $BtnBlackWhite
                _BlackAndWhite()
            
            Case $GUI_EVENT_RESTORE
                If $hImage Then _Update()
                
            Case $GUI_EVENT_CLOSE
                If $fChange Then
                    If _Save() Then
                        If $hImageContext Then _GDIPlus_GraphicsDispose($hImageContext)
                        If $hBackImage Then _GDIPlus_ImageDispose($hBackImage)
                        If $hImage Then _GDIPlus_ImageDispose($hImage)
                        _GDIPlus_ImageAttributesDispose($hIA)
                        _GDIPlus_GraphicsDispose($hGraphics)
                        ExitLoop
                    EndIf
                Else
                    ExitLoop
                EndIf
        EndSwitch
    WEnd

EndFunc

Func _Reset()
    Local $iI
    
    For $iI = 0 To UBound($aSliders)-1
         GUICtrlSetData($aSliders[$iI][2], _GetStringFormat($iI, $aSliders[$iI][5]))
        GUICtrlSetData($aSliders[$iI][0], $aSliders[$iI][5])
        $aSliders[$iI][8] = -1
    Next
    
    _GDIPlus_ImageAttributesSetThreshold($hIA, 0, False)
    If $hImage Then _Update()
EndFunc

Func _Save()
    Local $iRet
    
    If $fChange Then
        $iRet = MsgBox(0x23, "Save changes", 'Would you like to save changes to "' & StringTrimLeft($sImage, StringInStr($sImage, "\", 0, -1)) & '"?')
        
        If $iRet = 2 Then
            Return False
        ElseIf $iRet = 6 Then
            _GDIPlus_ImageSaveToFile($hBackImage, $sImage)
        EndIf
    EndIf
    
    Return True
EndFunc

Func _Initialize()
    $tPreHue = _GDIPlus_ColorMatrixCreate()
    $tPostHue = _GDIPlus_ColorMatrixCreate()
    _GDIPlus_ColorMatrixInitHue($tPreHue, $tPostHue)
    
    
    $aImageSize = _GDIPlus_ImageGetDimension($hImage)
    _GDIPlus_GraphicsDrawImageRect($hGraphics, $hImage, 0, 0, $iPicWidth, $iPicHeight)
    _Reset()
    $fChange = False
EndFunc

Func _Update()
    Local $tColorMatrix, $pColorMatrix, $nContrast, $nBrightness, $nSaturation, $nHue, $nGamma
    
    $tColorMatrix = _GDIPlus_ColorMatrixCreate()
    $pColorMatrix = DllStructGetPtr($tColorMatrix)
    
    $nContrast = _GetValue(0)
    $nBrightness = _GetValue(1)
    $nSaturation = _GetValue(2)
    $nHue = _GetValue(3)
    $nGamma = _GetValue(4)
    
    _GDIPlus_ColorMatrixScale($tColorMatrix, $nContrast, $nContrast, $nContrast, 1, 1)
    _GDIPlus_ColorMatrixTranslate($tColorMatrix, $nBrightness, $nBrightness, $nBrightness, 0, 1)
    _GDIPlus_ColorMatrixSetSaturation($tColorMatrix, $nSaturation, 1)
    _GDIPlus_ColorMatrixRotateHue($tColorMatrix, $tPreHue, $tPostHue, $nHue)
    
    _GDIPlus_ImageAttributesSetColorMatrix($hIA, 0, True, $pColorMatrix)
    _GDIPlus_ImageAttributesSetGamma($hIA, 0, True, $nGamma)
    
    _GDIPlus_GraphicsDrawImageRectRectIA($hImageContext, $hImage, 0, 0, $aImageSize[0], $aImageSize[1], 0, 0, $aImageSize[0], $aImageSize[1], $hIA)
    _GDIPlus_GraphicsDrawImageRectRect($hGraphics, $hBackImage, 0, 0, $aImageSize[0], $aImageSize[1], 0, 0, $iPicWidth, $iPicHeight)
EndFunc

Func _GetValue($iIndex)
    Return GUICtrlRead($aSliders[$iIndex][0])*$aSliders[$iIndex][6]
EndFunc

Func _GetStringFormat($iIndex, $iVal)
    If $aSliders[$iIndex][7] Then
        Return StringFormat("%." & $aSliders[$iIndex][7] & "f", $iVal*$aSliders[$iIndex][6])
    Else
        Return StringFormat("%d", $iVal*$aSliders[$iIndex][6])
    EndIf
EndFunc

Func _BlackAndWhite()
    Local $tBWMatrix, $pBWMatrix
    
    If $hImage Then
        _GDIPlus_ImageAttributesSetThreshold($hIA, 0, True, 0.5)
        $tBWMatrix = _GDIPlus_ColorMatrixCreateGrayScale()
        $pBWMatrix = DllStructGetPtr($tBWMatrix)
        
        _GDIPlus_ImageAttributesSetColorMatrix($hIA, 0, True, $pBWMatrix)
        _GDIPlus_GraphicsDrawImageRectRectIA($hImageContext, $hImage, 0, 0, $aImageSize[0], $aImageSize[1], 0, 0, $aImageSize[0], $aImageSize[1], $hIA)
        _GDIPlus_GraphicsDrawImageRectRect($hGraphics, $hBackImage, 0, 0, $aImageSize[0], $aImageSize[1], 0, 0, $iPicWidth, $iPicHeight)
        $fChange = True
    EndIf
EndFunc

Func _WM_HSCROLL($hWnd, $iMsg, $iwParam, $ilParam)
    Local $iI, $iPos, $iCode
    
    $iCode = BitAND($iwParam, 0xFFFF)
    If $iCode = $SB_ENDSCROLL Or $iCode = $SB_THUMBPOSITION Then Return 0
    
    For $iI = 0 To UBound($aSliders)-1
        If $aSliders[$iI][1] = $ilParam Then
            $iPos = GUICtrlRead($aSliders[$iI][0])
            
            If $iPos <> $aSliders[$iI][8] Then
                GUICtrlSetData($aSliders[$iI][2], _GetStringFormat($iI, $iPos))
                $aSliders[$iI][8] = $iPos
                
                If $hImage Then
                    $fChange = True
                    _Update()
                EndIf
            EndIf
            ExitLoop
        EndIf
    Next
  
    Return $GUI_RUNDEFMSG
EndFunc

Func _WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
    Local $tNMHDR, $hFrom, $iCode,  $iCommand, $sFileName, $sFile, $sExt, $sTmp, $hBitmap, $hContext
    
    $tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
    $hFrom = DllStructGetData($tNMHDR, "hWndFrom")
    $iCode = DllStructGetData($tNMHDR, "Code")
    
    If $hFrom = $hToolbar And $iCode = $NM_LDOWN Then
        Local $iCommand = _GUICtrlToolbar_IndexToCommand($hToolbar, _GUICtrlToolbar_GetHotItem($hToolbar))
        
        Switch $iCommand
            Case $idOpen
                $sFileName = FileOpenDialog("Open File", @WorkingDir, $sImageFormats, 3)
                    
                If $sFileName Then
                    If _Save() Then
                        $sImage = $sFileName
                        
                        If $hImage Then
                            _GDIPlus_GraphicsDispose($hImageContext)
                            _GDIPlus_ImageDispose($hBackImage)
                            _GDIPlus_ImageDispose($hImage)
                            $hImage = 0
                            $hBackImage = 0
                            $hImageContext = 0
                            $sImage = ""
                        EndIf
                        
                        $hBitmap = _GDIPlus_ImageLoadFromFile($sFileName)
                        If @error Then
                            MsgBox(0x10, "Error", "Could not load image")
                            _Reset()
                            $fChange = False
                        Else
                            $hImage = _GDIPlus_BitmapCreateFromScan0(_GDIPlus_ImageGetWidth($hBitmap), _GDIPlus_ImageGetHeight($hBitmap))
                            $hContext = _GDIPlus_ImageGetGraphicsContext($hImage)
                            _GDIPlus_GraphicsDrawImage($hContext, $hBitmap, 0, 0)
                            _GDIPlus_GraphicsDispose($hContext)
                            _GDIPlus_ImageDispose($hBitmap)
                            $hBackImage = _GDIPlus_ImageClone($hImage)
                            $hImageContext = _GDIPlus_ImageGetGraphicsContext($hBackImage)
                            _Initialize()
                        EndIf
                    EndIf
                EndIf
            Case $idSave
                If $hImage Then
                    $sFile = StringTrimLeft($sImage, StringInStr($sImage, "\", 0, -1))
                    $sExt = StringTrimLeft($sFile, StringInStr($sFile, ".", 0, -1))
                    
                    $sFileName = FileSaveDialog("Save As", @WorkingDir, $sImageFormats, 18, $sFile)
                    
                    If $sFileName Then
                        If StringRight($sFileName, StringLen($sExt)+1) <> "." & $sExt Then $sFileName &= "." & $sExt
                        _GDIPlus_ImageSaveToFile($hBackImage, $sFileName)
                        $fChange = False
                    EndIf
                EndIf
        EndSwitch
    EndIf
    
    Return $GUI_RUNDEFMSG
EndFunc

..and an image for testing.

post-45291-12601294526858_thumb.jpg

Edited by Authenticity
Link to comment
Share on other sites

You did the documentation for each function - great work! :)

Continuing with analyse of some interessting GDI+ functions...

UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

Unfortunately the fill functions (texture or patterns) are not as expected. It is only a static backround image and not real fill in object!

Example:

;coded by UEZ 2009
#include <GUIConstantsEx.au3>
#include <GDIplus.au3>
#include <WindowsConstants.au3>

Global Const $width = @DesktopWidth / 2
Global Const $height = @DesktopHeight / 2

Opt("GUIOnEventMode", 1)
Global $hwnd = GUICreate("Border Collision!", $width, $height, -1, -1, Default, BitOR($WS_EX_TOPMOST, $WS_EX_TOOLWINDOW))
GUISetOnEvent($GUI_EVENT_CLOSE, "close")
GUISetState()

_GDIPlus_Startup()
Global $graphics = _GDIPlus_GraphicsCreateFromHWND($hwnd)
Global $bitmap = _GDIPlus_BitmapCreateFromGraphics($width, $height, $graphics)
Global $backbuffer = _GDIPlus_ImageGetGraphicsContext($bitmap)
_GDIPlus_GraphicsClear($backbuffer)
_GDIPlus_GraphicsSetSmoothingMode($backbuffer, 4)

Global $max_dots = 20
Global $max_speed = 5
Global $iWidth = 60
Global $iHeight = 60
Dim $coordinates[$max_dots][5], $angle
Dim $brush[$max_dots]
Initialize()

Do
    _GDIPlus_GraphicsClear($backbuffer, 0xFF000000)
    Draw_Dots()
    Calculate_New_Position()
    _GDIPlus_GraphicsDrawImageRect($graphics, $bitmap, 0, 0, $width, $height)
    Sleep(30)
Until False

Func Initialize()
    For $k = 0 To $max_dots - 1
        $brush[$k] = _GDIPlus_HatchBrushCreate(Random(0, 52, 1), 0xFF0000FF, 0xFFFFFFFF)
        New_Coordinates($k)
    Next
EndFunc ;==>Initialize

Func Draw_Dots()
    Local $i, $temp_x, $temp_y
    For $i = 0 To $max_dots - 1
        _GDIPlus_GraphicsFillEllipse($backbuffer, $coordinates[$i][0], $coordinates[$i][1], $iWidth, $iHeight, $brush[$i])
    Next
EndFunc ;==>Draw_Dots

Func New_Coordinates($k)
    $coordinates[$k][0] = $width / 2 ;Random($width / 20, $width - $width / 20, 1);start x position
    $coordinates[$k][1] = $height / 2 ;Random($height / 20, $height - $height / 20, 1) ;start y position
    $coordinates[$k][2] = Random(1, $max_speed, 1) ;speed of pixel
    $angle = Random(0, 359, 1)
;~ ConsoleWrite("Angle: " & $angle & "°" & @CRLF)
    $coordinates[$k][3] = $coordinates[$k][2] * Cos($angle * 3.141592653 / 180)
    $coordinates[$k][4] = $coordinates[$k][2] * Sin($angle * 3.141592653 / 180)
EndFunc ;==>New_Coordinates

Func Calculate_New_Position()
    Local $k
    For $k = 0 To $max_dots - 1
        $coordinates[$k][0] += $coordinates[$k][3] ;increase x coordinate with appropriate slope
        $coordinates[$k][1] += $coordinates[$k][4] ;increase y coordinate with appropriate slope
        If $coordinates[$k][0] <= 0 Then ;border collision x left
            $coordinates[$k][0] = 1
            $coordinates[$k][3] *= -1
        ElseIf $coordinates[$k][0] >= $width - $iWidth Then ;border collision x right
            $coordinates[$k][0] = $width - ($iWidth + 1)
            $coordinates[$k][3] *= -1
        EndIf
        If $coordinates[$k][1] <= 0 Then ;border collision y top
            $coordinates[$k][1] = 1
            $coordinates[$k][4] *= -1
        ElseIf $coordinates[$k][1] >= $height - $iHeight Then ;border collision y bottom
            $coordinates[$k][1] = $height - ($iHeight + 1)
            $coordinates[$k][4] *= -1
        EndIf
    Next
EndFunc ;==>Calculate_New_Position


Func close()
    For $k = 0 To $max_dots - 1
        _GDIPlus_BrushDispose($brush[$k])
    Next
    _GDIPlus_BitmapDispose($bitmap)
    _GDIPlus_GraphicsDispose($graphics)
    _GDIPlus_GraphicsDispose($backbuffer)
    _GDIPlus_Shutdown()
    Exit
EndFunc ;==>close


Func _GDIPlus_HatchBrushCreate($iHatchStyle = 0, $iARGBForeground = 0xFFFFFFFF, $iARGBBackground = 0xFFFFFFFF)
    Local $aResult = DllCall($ghGDIPDll, "uint", "GdipCreateHatchBrush", "int", $iHatchStyle, "uint", $iARGBForeground, "uint", $iARGBBackground, "int*", 0)

    If @error Then Return SetError(@error, @extended, 0)
    Return SetError($aResult[0], 0, $aResult[4])
EndFunc ;==>_GDIPlus_HatchBrushCreate

I did not find a real fill function! :)

UEZ

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

Can I fill e.g. an area (in your example) with a texture (image) whereas the texture matches the area?

UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

This UDF is just a wrapper around GDIPlus.au3 to include the rest of the exports.

History:

Update 06.12.2009:
 - Added a few ColorMatrix manipulation functions, see top of the page for acknowledges.
 - Added a few more examples to the ImageAttribute object.

Update 04.12.2009:
 - Added a few more examples for InstalledCollection, Graphics, GraphicsContainer.
 - Fixed _GDIPlus_GraphicsDrawRectangles and _GDIPlus_GraphicsFillRectangles functions
 - Fixed a few examples that used some old functions syntax

Update 03.12.2009:
 - Added function descriptions.
 - A few function definitions have been redefined to be consistent with return and parameters values.
 - No additional examples at the moment.

Thanks for sharing!

You have done big good work.

With all standard description headers you can add it as proposition for adding to standard includes, just make ticket for it on Trac.

I think lack of examples for all included functions is not problem here. There are many standard UDFs without examples already.

I'm looking forward to new Autoit's beta with this included :-)

Link to comment
Share on other sites

Can I fill e.g. an area (in your example) with a texture (image) whereas the texture matches the area?

UEZ

Now I looked at your code (EDIT: from post #9) and I tried to run it.

I think you should use _GDIPlus_GraphicsFillEllipse() with constant X,Y coordinates to achieve your goal.

Maybe prepare memory bitmap with all drawn elipses and in main cycle just use BitBlt from this memory bitmap for each elipse.

Edited by Zedna
Link to comment
Share on other sites

Now I looked at your code and I tried to run it.

I think you should use _GDIPlus_GraphicsFillEllipse() with constant X,Y coordinates to achieve your goal.

Maybe prepare memory bitmap with all drawn elipses and in main cycle just use BitBlt from this memory bitmap for each elipse.

You mean my example above: #751337 ?

I tried also _GDIPlus_TextureCreate() and assigned an image but the image will be static in the background. If you try to fill it with _GDIPlus_GraphicsFillEllipse() you will see within the moving ellipse the image partly (clipping of coordinate where the moving ellipse is).

UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

I guess the the idea behind the texture and the hatch brushes is that the area behind it should be static. What you're asking is more like:

;coded by UEZ 2009
#include <GUIConstantsEx.au3>
#include <GDIP.au3>
#include <WindowsConstants.au3>

Global Const $width = @DesktopWidth / 2
Global Const $height = @DesktopHeight / 2

Opt("GUIOnEventMode", 1)
Global $hwnd = GUICreate("Border Collision!", $width, $height, -1, -1, Default, BitOR($WS_EX_TOPMOST, $WS_EX_TOOLWINDOW))
GUISetOnEvent($GUI_EVENT_CLOSE, "close")
GUISetState()

_GDIPlus_Startup()
Global $graphics = _GDIPlus_GraphicsCreateFromHWND($hwnd)
Global $bitmap = _GDIPlus_BitmapCreateFromGraphics($width, $height, $graphics)
Global $backbuffer = _GDIPlus_ImageGetGraphicsContext($bitmap)
_GDIPlus_GraphicsClear($backbuffer)
_GDIPlus_GraphicsSetSmoothingMode($backbuffer, 4)

Global $max_dots = 20
Global $max_speed = 5
Global $iWidth = 60
Global $iHeight = 60
Dim $coordinates[$max_dots][5], $angle
Dim $brush[$max_dots]
Global $hImage[$max_dots]
Global $hContext
Global $hBrush
Initialize()

Do
    _GDIPlus_GraphicsClear($backbuffer, 0xFF000000)
    Draw_Dots()
    Calculate_New_Position()
    _GDIPlus_GraphicsDrawImageRect($graphics, $bitmap, 0, 0, $width, $height)
    Sleep(30)
Until False

Func Initialize()
    For $k = 0 To $max_dots - 1
        $hImage[$k] = _GDIPlus_BitmapCreateFromScan0($iWidth, $iHeight)
        
        $hBrush = _GDIPlus_HatchBrushCreate(Random(0, 52, 1), 0xFF0000FF, 0xFFFFFFFF)
        $hContext = _GDIPlus_ImageGetGraphicsContext($hImage[$k])
        _GDIPlus_GraphicsFillEllipse($hContext, 0, 0, $iWidth, $iWidth, $hBrush)
        _GDIPlus_GraphicsDispose($hContext)
        _GDIPlus_BrushDispose($hBrush)
        New_Coordinates($k)
    Next
EndFunc ;==>Initialize

Func Draw_Dots()
    Local $i, $temp_x, $temp_y
    For $i = 0 To $max_dots - 1
        _GDIPlus_GraphicsDrawImageRect($backbuffer, $hImage[$i], $coordinates[$i][0], $coordinates[$i][1], $iWidth, $iHeight)
    Next
EndFunc ;==>Draw_Dots

Func New_Coordinates($k)
    $coordinates[$k][0] = $width / 2 ;Random($width / 20, $width - $width / 20, 1);start x position
    $coordinates[$k][1] = $height / 2 ;Random($height / 20, $height - $height / 20, 1) ;start y position 
    $coordinates[$k][2] = Random(1, $max_speed, 1) ;speed of pixel
    $angle = Random(0, 359, 1)
;~ ConsoleWrite("Angle: " & $angle & "°" & @CRLF)
    $coordinates[$k][3] = $coordinates[$k][2] * Cos($angle * 3.141592653 / 180)
    $coordinates[$k][4] = $coordinates[$k][2] * Sin($angle * 3.141592653 / 180)
EndFunc ;==>New_Coordinates

Func Calculate_New_Position()
    Local $k
    For $k = 0 To $max_dots - 1
        $coordinates[$k][0] += $coordinates[$k][3] ;increase x coordinate with appropriate slope
        $coordinates[$k][1] += $coordinates[$k][4] ;increase y coordinate with appropriate slope
        If $coordinates[$k][0] <= 0 Then ;border collision x left
            $coordinates[$k][0] = 1
            $coordinates[$k][3] *= -1
        ElseIf $coordinates[$k][0] >= $width - $iWidth Then ;border collision x right
            $coordinates[$k][0] = $width - ($iWidth + 1)
            $coordinates[$k][3] *= -1
        EndIf
        If $coordinates[$k][1] <= 0 Then ;border collision y top
            $coordinates[$k][1] = 1
            $coordinates[$k][4] *= -1
        ElseIf $coordinates[$k][1] >= $height - $iHeight Then ;border collision y bottom
            $coordinates[$k][1] = $height - ($iHeight + 1)
            $coordinates[$k][4] *= -1
        EndIf
    Next
EndFunc ;==>Calculate_New_Position


Func close()
    For $k = 0 To $max_dots-1
        _GDIPlus_ImageDispose($hImage[$k])
    Next
    _GDIPlus_BitmapDispose($bitmap)
    _GDIPlus_GraphicsDispose($graphics)
    _GDIPlus_GraphicsDispose($backbuffer)
    _GDIPlus_Shutdown()
    Exit
EndFunc ;==>close
Link to comment
Share on other sites

I guess the the idea behind the texture and the hatch brushes is that the area behind it should be static. What you're asking is more like:

YES, exactly what I searched. I will try it also for the texture function! Well done!

How did you find the way?

Thanks,

UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

While experimenting, but that was the first and only experiment anyway :)

I know think about adding the GDI+ v1.1 functions, mainly the effects and that, but it's not going to be part of the GDIPlus.au3 compliant, rather a different branch of GDIP.au3, call it GDIPlus11.au3 or something but I don't know. What you think? Example:

#include <GDIPlus.au3>

Global Const $GDIP_BLUREFFECT = "{633C80A4-1843-482b-9EF2-BE2834C5FDD4}"
Global Const $GDIP_SHARPENEFFECT = "{63CBF3EE-C526-402c-8F71-62C540BF5142}"
Global Const $GDIP_COLORMATRIXEFFECT = "{718F2615-7933-40e3-A511-5F68FE14DD74}"
Global Const $GDIP_COLORLUTEFFECT = "{A7CE72A9-0F7F-40d7-B3CC-D0C02D5C3212}"
Global Const $GDIP_BRIGHTNESSCONTRASTEFFECT = "{D3A1DBE1-8EC4-4c17-9F4C-EA97AD1C343D}"
Global Const $GDIP_HUESATURATIONLIGHTNESSEFFECT = "{8B2DD6C3-EB07-4d87-A5F0-7108E26A9C5F}"
Global Const $GDIP_LEVELSEFFECT = "{99C354EC-2A31-4f3a-8C34-17A803B33A25}"
Global Const $GDIP_TINTEFFECT = "{1077AF00-2848-4441-9489-44AD4C2D7A2C}"
Global Const $GDIP_COLORBALANCEEFFECT = "{537E597D-251E-48da-9664-29CA496B70F8}"
Global Const $GDIP_REDEYECORRECTIONEFFECT = "{74D29D05-69A4-4266-9549-3CC52836B632}"
Global Const $GDIP_COLORCURVEEFFECT = "{DD6A0022-58E4-4a67-9D9B-D48EB881A53D}"

_GDIPlus11_Startup()
If @error Then Exit MsgBox(0x10, "Error", "GDIPlus v1.1 is not installed")

Local $hGUI, $hGraphics, $hImage, $hBlurredImage,  $hEffect

$hGUI = GUICreate("", 640, 480)
GUISetState()

$hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI)
$hImage = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\flowers.jpg")
$hEffect = _GDIPlus_EffectCreate($GDIP_BLUREFFECT)
$hBlurredImage = _GDIPlus_BitmapCreateWithEffect($hImage, $hEffect)

_GDIPlus_GraphicsDrawImage($hGraphics, $hBlurredImage, 0, 0)

Do
Until GUIGetMsg() = -3

_GDIPlus_BitmapDispose($hBlurredImage)
_GDIPlus_EffectDispose($hEffect)
_GDIPlus_ImageDispose($hImage)
_GDIPlus_GraphicsDispose($hGraphics)

_GDIPlus11_Shutdown()


Func _GDIPlus_BitmapApplyEffect($hBitmap, $hEffect, $pROI = 0)
    Local $aResult = DllCall($ghGDIPDll, "uint", "GdipBitmapApplyEffect", "hwnd", $hBitmap, "hwnd", $hEffect, "ptr", $pROI, "int", 0, "ptr*", 0, "int*", 0)
    If @error Then Return SetError(@error, @extended, 0)

    Return SetError($aResult[0], 0, $aResult[0] = 0)
EndFunc

Func _GDIPlus_BitmapCreateWithEffect($hBitmap, $hEffect, $pROI = 0, $pOutRect = 0)
    Local $aResult = DllCall($ghGDIPDll, "uint", "GdipBitmapCreateApplyEffect", "ptr*", $hBitmap, "int", 1, "hwnd", $hEffect, "ptr", $pROI, "ptr", $pOutRect, "int*", 0, "int", 0, "ptr*", 0, "int*", 0)
    If @error Then Return SetError(@error, @extended, 0)

    Return SetError($aResult[0], 0, $aResult[6])
EndFunc

Func _GDIPlus_EffectCreate($sEffectGUID)
    Local $iI, $tGUID, $pGUID, $tElem, $aElem[4], $aResult
    
    $tGUID = _WinAPI_GUIDFromString($sEffectGUID)
    $pGUID = DllStructGetPtr($tGUID)
    
    $tElem = DllStructCreate("int[4]", $pGUID)
    For $iI = 1 To 4
        $aElem[$iI-1] = DllStructGetData($tElem, 1, $iI)
    Next
    
    $aResult = DllCall($ghGDIPDll, "uint", "GdipCreateEffect", "int", $aElem[0], "int", $aElem[1], "int", $aElem[2], "int", $aElem[3], "int*", 0)
    If @error Then Return SetError(@error, @extended, 0)
    Return SetError($aResult[0], 0, $aResult[5])
EndFunc

Func _GDIPlus_EffectDispose($hEffect)
    Local $aResult = DllCall($ghGDIPDll, "uint", "GdipDeleteEffect", "hwnd", $hEffect)
    
    If @error Then Return SetError(@error, @extended, 0)
    Return SetError($aResult[0], 0, $aResult[0] = 0)
EndFunc

Func _GDIPlus11_Startup()
    Local $pInput, $tInput, $pToken, $tToken, $aResult

    $giGDIPRef += 1
    If $giGDIPRef > 1 Then Return True

    $ghGDIPDll = DllOpen(@WindowsDir & "\winsxs\x86_microsoft.windows.gdiplus_6595b64144ccf1df_1.1.6000.16386_none_8df21b8362744ace\gdiplus.dll")
    _WinAPI_Check("_GDIPlus_Startup (GDIPlus.dll not found)", @error, False)

    $tInput = DllStructCreate($tagGDIPSTARTUPINPUT)
    $pInput = DllStructGetPtr($tInput)
    $tToken = DllStructCreate("int Data")
    $pToken = DllStructGetPtr($tToken)
    DllStructSetData($tInput, "Version", 1)
    $aResult = DllCall($ghGDIPDll, "int", "GdiplusStartup", "ptr", $pToken, "ptr", $pInput, "ptr", 0)
    If @error Then Return SetError(@error, @extended, False)
    $giGDIPToken = DllStructGetData($tToken, "Data")
    Return $aResult[0] == 0
EndFunc

Func _GDIPlus11_Shutdown()
    If $ghGDIPDll = 0 Then Return SetError(-1, -1, False)

    $giGDIPRef -= 1
    If $giGDIPRef = 0 Then
        DllCall($ghGDIPDll, "none", "GdiplusShutdown", "ptr", $giGDIPToken)
        DllClose($ghGDIPDll)
        $ghGDIPDll = 0
    EndIf
    Return True
EndFunc

By the way, GDI+ v1.1 is distributed on Vista machines and up, so it's another problem.

Link to comment
Share on other sites

The thing is to understand the functionality of all GDI+ functions. The names are not always clear to me what function is behind. Experimenting is probably the best way to check it out.

GDI+ v1.1 would be nice, too. It is possible to do some image manipulation.

Great job Authenticity!

Thanks,

UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

The thing is to understand the functionality of all GDI+ functions. The names are not always clear to me what function is behind. Experimenting is probably the best way to check it out.

...

The functions naming is, as Paul Campbell did: The object the particular function applies comes first, followed by the verb and optionally the object or structure it's expecting. for example, GdipDrawEllipse is not relating to the graphics by it's name but it for sure exposed by the Graphics object so it becomes: _GDIPlus_GraphicsDrawRect. Another example is the GdipAddPathRectangle which becomes _GDIPlus_PathAddRectangle. Can you give an example of such function naming ambiguity? In any case I guess that the function's description is very helpful as MSDN can be ;)

Thanks UEZ.

Link to comment
Share on other sites

Can you give an example of such function naming ambiguity? In any case I guess that the function's description is very helpful as MSDN can be ;)

Thanks UEZ.

I mean not ambiguity of function names but rather comprehensibility of function names. E.g. _GDIPlus_BitmapCreateFromScan0() (description: Creates a Bitmap object based on an array of bytes along with size and format information). This function was not intuitively understandable for me before you showed the example.

Also there are some more functions where I don't know what they are doing exactly. In that case I've to search e.g. at MSDN for a detailed decsription.

UEZ

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...