Authenticity Posted November 27, 2009 Share Posted November 27, 2009 (edited) I'd like to list the following resources which I've found very useful, most of this is from there:GDI+ ClassesJosé Roca's GDI+ reference and forumdeveloppez, 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_TextureTranslateTransformI'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. History:expandcollapse popupUpdate 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 December 27, 2010 by Authenticity Link to comment Share on other sites More sharing options...
UEZ Posted November 27, 2009 Share Posted November 27, 2009 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 More sharing options...
trancexx Posted November 29, 2009 Share Posted November 29, 2009 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 More sharing options...
Uriziel01 Posted November 29, 2009 Share Posted November 29, 2009 (edited) 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 November 29, 2009 by Uriziel01 Link to comment Share on other sites More sharing options...
Authenticity Posted November 29, 2009 Author Share Posted November 29, 2009 (edited) 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 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! 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 November 29, 2009 by Authenticity Link to comment Share on other sites More sharing options...
UEZ Posted December 6, 2009 Share Posted December 6, 2009 (edited) Here an example with _GDIPlus_HatchBrushCreate() function (53 fill patterns):Nothing special but imho worth mentioning.expandcollapse popup;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_HatchBrushCreateThanks to Authenticity for the additional GDI+ function. Currently I'm searching within the functions for some nice functions...Have a nice Santa ClausUEZ Edited December 6, 2009 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 More sharing options...
Authenticity Posted December 6, 2009 Author Share Posted December 6, 2009 (edited) 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:expandcollapse popup#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. Edited December 6, 2009 by Authenticity wakillon 1 Link to comment Share on other sites More sharing options...
UEZ Posted December 6, 2009 Share Posted December 6, 2009 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 More sharing options...
UEZ Posted December 6, 2009 Share Posted December 6, 2009 (edited) 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: expandcollapse popup;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 December 6, 2009 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 More sharing options...
Zedna Posted December 6, 2009 Share Posted December 6, 2009 I did not find a real fill function! UEZDid you mean FloodFill GDI API?Here is my example for that:http://www.autoitscript.com/forum/index.php?s=&showtopic=45978&view=findpost&p=344974 Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
UEZ Posted December 6, 2009 Share Posted December 6, 2009 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 More sharing options...
Zedna Posted December 6, 2009 Share Posted December 6, 2009 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 :-) Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
Zedna Posted December 7, 2009 Share Posted December 7, 2009 (edited) Can I fill e.g. an area (in your example) with a texture (image) whereas the texture matches the area?UEZNow 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 December 7, 2009 by Zedna Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
UEZ Posted December 7, 2009 Share Posted December 7, 2009 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 More sharing options...
Authenticity Posted December 7, 2009 Author Share Posted December 7, 2009 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: expandcollapse popup;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 More sharing options...
UEZ Posted December 7, 2009 Share Posted December 7, 2009 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 More sharing options...
Authenticity Posted December 7, 2009 Author Share Posted December 7, 2009 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: expandcollapse popup#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 More sharing options...
UEZ Posted December 8, 2009 Share Posted December 8, 2009 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 More sharing options...
Authenticity Posted December 8, 2009 Author Share Posted December 8, 2009 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 More sharing options...
UEZ Posted December 8, 2009 Share Posted December 8, 2009 (edited) 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 December 8, 2009 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now