News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

GDI+

Started by jj2007, January 18, 2016, 09:45:51 PM

Previous topic - Next topic

jj2007

GdiPlus is a powerful API with more than 600 functions. MSDN docs focus on C wrappers, while finding documentation for the "flat" version, which is more suitable for Masm, is more difficult. There is the José Roca site, though - excellent if you know already what you are looking for.

Since often I don't know what to pick from the 624 functions I found so far, I extracted basic info from the Visual Express help docs and condensed them into a single file for fast searching. For example, if you are working with Bezier functions, you can type (in RichMasm) gdi+_***bez and hit Enter to get the results in the screenshot below, where
  gdi+_ is the identifier for an entry
  *** means "within three lines, including the current", and
  bez is the string you are searching for.

Replace bez with bitm to see a listing of 32 bitmap-related functions.

Each entry has
- the "flat" syntax, e.g.
gdi+_57   GdipGetCustomLineCapWidthScale(GpCustomLineCap* customCap, REAL* widthScale)

- a description, e.g.
desc   The CustomLineCap::GetWidthScale method gets the value of the scale width. This is the amount to scale...

- the C wrapper syntax, e.g.
cw   CustomLineCap::GetWidthScale

P.S.: The attached *.asc file is in RTF format. Opens best in RichMasm, but MS Word or Wordpad are fine, too. No bookmarks, though, and the Find function sucks :(

Grincheux

How to load an image (bmp, gif, jpg, png) using gdi+


IMAGEINFOS STRUCT
Bmi BITMAPINFO <>
ALIGN 16
    Start BYTE ?
IMAGEINFOS ENDS

LPIMAGEINFOS TYPEDEF PTR IMAGEINFOS

; INVOKE LoadImage,ADDR szTheImage,ADDR hNewBitmap,ADDR dwImageWidth,ADDR dwImageHeight

; LoadImage return the image width and height into the dwImageWidth and dwImageHeight parameter
;hBitmap = LoadImage(szTheImage,&hNewBitmap,&ImageWidth,&ImageHeight) ;

; If there is an error EAX = NULL


; ==================================================================================
ALIGN 16
; ==================================================================================

Load_Image PROC __lpszFileName:LPSTR,__lphBitmap:PTR HBITMAP,__lpdwWidth:Ptr DWord,__lpdwHeight:Ptr DWord
LOCAL _hInputImage:DWord
LOCAL _szTmpFileName[MAX_PATH * 2]:Byte

mov eax,__lphBitmap
mov DWord Ptr [eax],NULL

INVOKE MultiByteToWideChar,CP_OEMCP,MB_PRECOMPOSED,__lpszFileName,-1,ADDR _szTmpFileName,SIZEOF _szTmpFileName
INVOKE GdipLoadImageFromFile,ADDR _szTmpFileName,ADDR _hInputImage

test eax,eax
jnz @Load_Image_Error_1

cmp _hInputImage,NULL
je @Load_Image_Error_1

INVOKE GdipGetImageWidth,_hInputImage,__lpdwWidth
INVOKE GdipGetImageHeight,_hInputImage,__lpdwHeight

push 000000h
push __lphBitmap
push _hInputImage
push OFFSET @Load_Image_Error_1
jmp GdipCreateHBITMAPFromBitmap

; **********************************************************************************
ALIGN 16
; **********************************************************************************

@Load_Image_Error_1 :

push _hInputImage
push OFFSET @Load_Image_Exit
jmp GdipDisposeImage

; **********************************************************************************
ALIGN 16
; **********************************************************************************

@Load_Image_Exit :

mov eax,__lphBitmap
mov eax,[eax]
ret
Load_Image ENDP

jj2007

Quote from: Grincheux on January 18, 2016, 11:26:52 PM
How to load an image (bmp, gif, jpg, png) using gdi+

Searching with gdi+_***image:

gdi+_10 GdipCreateBitmapFromStream(IStream* stream, GpBitmap **bitmap)
gdi+_11 GdipCreateBitmapFromFile(WCHAR* filename, GpBitmap **bitmap)
gdi+_13 GdipCreateBitmapFromFileICM(WCHAR* filename, GpBitmap **bitmap)
gdi+_36 GdipTestControl(GpTestControlEnum control, void * param)
gdi+_42 GdipDrawCachedBitmap( *graphics, GpCachedBitmap *cachedBitmap, INT x, INT y )
gdi+_97 GdipCreateFromHWNDICM(HWND hwnd, **graphics)
gdi+_115 GdipSetInterpolationMode(*graphics, InterpolationMode interpolationMode)
gdi+_117 GdipGetInterpolationMode(*graphics, InterpolationMode *interpolationMode)
gdi+_186 GdipDrawImage(*graphics, GpImage *image, REAL x, REAL y)
gdi+_187 GdipDrawImageI(*graphics, GpImage *image, INT x, INT y)
gdi+_188 GdipDrawImageRect(*graphics, GpImage *image, REAL x, REAL y, REAL width, REAL height)
gdi+_189 GdipDrawImageRectI(*graphics, GpImage *image, INT x, INT y, INT width, INT height)
gdi+_190 GdipDrawImagePoints(*graphics, GpImage *image, GpPointF *dstpoints, INT count)
gdi+_191 GdipDrawImagePointsI(*graphics, GpImage *image, GpPoint *dstpoints, INT count)
gdi+_192 GdipDrawImagePointRect(*graphics, GpImage *image, REAL x, REAL y, REAL srcx, REAL srcy, REAL srcwidth, REAL srcheight, G
gdi+_193 GdipDrawImagePointRectI(*graphics, GpImage *image, INT x, INT y, INT srcx, INT srcy, INT srcwidth, INT srcheight, GpUnit
gdi+_194 GdipDrawImageRectRect(*graphics, GpImage *image, REAL dstx, REAL dsty, REAL dstwidth, REAL dstheight, REAL srcx, REAL sr
gdi+_195 GdipDrawImageRectRectI(*graphics, GpImage *image, INT dstx, INT dsty, INT dstwidth, INT dstheight, INT srcx, INT srcy, I
gdi+_196 GdipDrawImagePointsRect(*graphics, GpImage *image, GpPointF *points, INT count, REAL srcx, REAL srcy, REAL srcwidth, REA
gdi+_197 GdipDrawImagePointsRectI(*graphics, GpImage *image, GpPoint *points, INT count, INT srcx, INT srcy, INT srcwidth, INT sr
gdi+_198 GdipDrawImageFX(*graphics, GpImage *image, GpRectF *source, GpMatrix *xForm, CGpEffect *effect, GpImageAttributes *image
gdi+_199 GdipEnumerateMetafileDestPoint( * graphics, GpMetafile * metafile, PointF &amp; destPoint, EnumerateMetafileProc callbac
gdi+_200 GdipEnumerateMetafileDestPointI( * graphics, GpMetafile * metafile, Point &amp; destPoint, EnumerateMetafileProc callbac
gdi+_201 GdipEnumerateMetafileDestRect( * graphics, GpMetafile * metafile, RectF &amp; destRect, EnumerateMetafileProc callback,
gdi+_202 GdipEnumerateMetafileDestRectI( * graphics, GpMetafile * metafile, Rect &amp; destRect, EnumerateMetafileProc callback,
gdi+_203 GdipEnumerateMetafileDestPoints( * graphics, GpMetafile * metafile, PointF * destPoints, INT count, EnumerateMetafilePro
gdi+_204 GdipEnumerateMetafileDestPointsI( * graphics, GpMetafile * metafile, Point * destPoints, INT count, EnumerateMetafilePro
gdi+_205 GdipEnumerateMetafileSrcRectDestPoint( * graphics, GpMetafile * metafile, PointF &amp; destPoint, RectF &amp; srcRect, U
gdi+_206 GdipEnumerateMetafileSrcRectDestPointI( * graphics, GpMetafile * metafile, Point &amp; destPoint, Rect &amp; srcRect, Un
gdi+_207 GdipEnumerateMetafileSrcRectDestRect( * graphics, GpMetafile * metafile, RectF &amp; destRect, RectF &amp; srcRect, Unit
gdi+_208 GdipEnumerateMetafileSrcRectDestRectI( * graphics, GpMetafile * metafile, Rect &amp; destRect, Rect &amp; srcRect, Unit
gdi+_209 GdipEnumerateMetafileSrcRectDestPoints( * graphics, GpMetafile * metafile, PointF * destPoints, INT count, RectF &amp; s
gdi+_210 GdipEnumerateMetafileSrcRectDestPointsI( * graphics, GpMetafile * metafile, Point * destPoints, INT count, Rect &amp; sr
gdi+_257 GdipGetImageDecodersSize(UINT *numDecoders, UINT *size)
gdi+_258 GdipGetImageDecoders(UINT numDecoders, UINT size, ImageCodecInfo *decoders)
gdi+_259 GdipGetImageEncodersSize(UINT *numEncoders, UINT *size)
gdi+_260 GdipGetImageEncoders(UINT numEncoders, UINT size, ImageCodecInfo *encoders)
gdi+_330 GdipLoadImageFromStream(IStream* stream, GpImage **image)
gdi+_331 GdipLoadImageFromFile(WCHAR* filename, GpImage **image)
gdi+_332 GdipLoadImageFromStreamICM(IStream* stream, GpImage **image)
gdi+_333 GdipLoadImageFromFileICM(WCHAR* filename, GpImage **image)
gdi+_334 GdipCloneImage(GpImage *image, GpImage **cloneImage)
gdi+_335 GdipDisposeImage(GpImage *image)
gdi+_336 GdipSaveImageToFile(GpImage *image, WCHAR* filename, CLSID* clsidEncoder, EncoderParameters* encoderParams)
gdi+_337 GdipSaveImageToStream(GpImage *image, IStream* stream, CLSID* clsidEncoder, EncoderParameters* encoderParams)
gdi+_338 GdipSaveAdd(GpImage *image, EncoderParameters* encoderParams)
gdi+_339 GdipSaveAddImage(GpImage *image, GpImage* newImage, EncoderParameters* encoderParams)
gdi+_340 GdipGetImageGraphicsContext(GpImage *image, **graphics)
gdi+_341 GdipGetImageBounds(GpImage *image, GpRectF *srcRect, GpUnit *srcUnit)
gdi+_342 GdipGetImageDimension(GpImage *image, REAL *width, REAL *height)
gdi+_343 GdipGetImageType(GpImage *image, ImageType *type)
gdi+_344 GdipGetImageWidth(GpImage *image, UINT *width)
gdi+_345 GdipGetImageHeight(GpImage *image, UINT *height)
gdi+_346 GdipGetImageHorizontalResolution(GpImage *image, REAL *resolution)
gdi+_347 GdipGetImageVerticalResolution(GpImage *image, REAL *resolution)
gdi+_348 GdipGetImageFlags(GpImage *image, UINT *flags)
gdi+_349 GdipGetImageRawFormat(GpImage *image, GUID *format)
gdi+_350 GdipGetImagePixelFormat(GpImage *image, PixelFormat *format)
gdi+_351 GdipGetImageThumbnail(GpImage *image, UINT thumbWidth, UINT thumbHeight, GpImage **thumbImage, GetThumbnailImageAbort ca
gdi+_352 GdipGetEncoderParameterListSize(GpImage *image, CLSID* clsidEncoder, UINT* size)
gdi+_353 GdipGetEncoderParameterList(GpImage *image, CLSID* clsidEncoder, UINT size, EncoderParameters* buffer)
gdi+_354 GdipImageGetFrameDimensionsCount(GpImage* image, UINT* count)
gdi+_355 GdipImageGetFrameDimensionsList(GpImage* image, GUID* dimensionIDs, UINT count)
gdi+_356 GdipImageGetFrameCount(GpImage *image, GUID* dimensionID, UINT* count)
gdi+_357 GdipImageSelectActiveFrame(GpImage *image, GUID* dimensionID, UINT frameIndex)
gdi+_358 GdipImageRotateFlip(GpImage *image, RotateFlipType rfType)
gdi+_359 GdipGetImagePalette(GpImage *image, ColorPalette *palette, INT size)
gdi+_360 GdipSetImagePalette(GpImage *image, ColorPalette *palette)
gdi+_361 GdipGetImagePaletteSize(GpImage *image, INT *size)
gdi+_362 GdipGetPropertyCount(GpImage *image, UINT* numOfProperty)
gdi+_363 GdipGetPropertyIdList(GpImage *image, UINT numOfProperty, PROPID* list)
gdi+_364 GdipGetPropertyItemSize(GpImage *image, PROPID propId, UINT* size)
gdi+_365 GdipGetPropertyItem(GpImage *image, PROPID propId,UINT propSize, PropertyItem* buffer)
gdi+_366 GdipGetPropertySize(GpImage *image, UINT* totalBufferSize, UINT* numProperties)
gdi+_367 GdipGetAllPropertyItems(GpImage *image, UINT totalBufferSize, UINT numProperties, PropertyItem* allItems)
gdi+_368 GdipRemovePropertyItem(GpImage *image, PROPID propId)
gdi+_369 GdipSetPropertyItem(GpImage *image, PropertyItem* item)
gdi+_370 GdipFindFirstImageItem(GpImage *image, ImageItemData* item)
gdi+_371 GdipFindNextImageItem(GpImage *image, ImageItemData* item)
gdi+_372 GdipGetImageItemData(GpImage *image, ImageItemData* item)
gdi+_373 GdipImageSetAbort(GpImage *pImage, GdiplusAbort *pIAbort)
gdi+_377 GdipImageForceValidation(GpImage *image)
gdi+_378 GdipCreateImageAttributes(GpImageAttributes **imageattr)
gdi+_379 GdipCloneImageAttributes(GpImageAttributes *imageattr, GpImageAttributes **cloneImageattr)
gdi+_380 GdipDisposeImageAttributes(GpImageAttributes *imageattr)
gdi+_381 GdipSetImageAttributesToIdentity(GpImageAttributes *imageattr, ColorAdjustType type)
gdi+_382 GdipResetImageAttributes(GpImageAttributes *imageattr, ColorAdjustType type)
gdi+_383 GdipSetImageAttributesColorMatrix(GpImageAttributes *imageattr, ColorAdjustType type, BOOL enableFlag, ColorMatrix* colo
gdi+_384 GdipSetImageAttributesThreshold(GpImageAttributes *imageattr, ColorAdjustType type, BOOL enableFlag, REAL threshold)
gdi+_385 GdipSetImageAttributesGamma(GpImageAttributes *imageattr, ColorAdjustType type, BOOL enableFlag, REAL gamma)
gdi+_386 GdipSetImageAttributesNoOp(GpImageAttributes *imageattr, ColorAdjustType type, BOOL enableFlag)
gdi+_387 GdipSetImageAttributesColorKeys(GpImageAttributes *imageattr, ColorAdjustType type, BOOL enableFlag, ARGB colorLow, ARGB
gdi+_388 GdipSetImageAttributesOutputChannel(GpImageAttributes *imageattr, ColorAdjustType type, BOOL enableFlag, ColorChannelFla
gdi+_389 GdipSetImageAttributesOutputChannelColorProfile(GpImageAttributes *imageattr, ColorAdjustType type, BOOL enableFlag, WCH
gdi+_390 GdipSetImageAttributesRemapTable(GpImageAttributes *imageattr, ColorAdjustType type, BOOL enableFlag, UINT mapSize, Colo
gdi+_391 GdipSetImageAttributesWrapMode(GpImageAttributes *imageAttr, WrapMode wrap, ARGB argb, BOOL clamp )
gdi+_392 GdipSetImageAttributesICMMode(GpImageAttributes *imageAttr, BOOL on )
gdi+_393 GdipGetImageAttributesAdjustedPalette(GpImageAttributes *imageAttr, ColorPalette * colorPalette, ColorAdjustType colorAd
gdi+_394 GdipSetImageAttributesCachedBackground(GpImageAttributes *imageattr, BOOL enableFlag)
gdi+_610 GdipCreateTexture(GpImage *image, GpWrapMode wrapmode, GpTexture **texture)
gdi+_611 GdipCreateTexture2(GpImage *image, GpWrapMode wrapmode, REAL x, REAL y, REAL width, REAL height, GpTexture **texture)
gdi+_612 GdipCreateTextureIA(GpImage *image, GpImageAttributes *imageAttributes, REAL x, REAL y, REAL width, REAL height, GpTextu
gdi+_613 GdipCreateTexture2I(GpImage *image, GpWrapMode wrapmode, INT x, INT y, INT width, INT height, GpTexture **texture)
gdi+_614 GdipCreateTextureIAI(GpImage *image, GpImageAttributes *imageAttributes, INT x, INT y, INT width, INT height, GpTexture
gdi+_624 GdipGetTextureImage(GpTexture *brush, GpImage **image)


Grincheux

I had found a web site that seemed well to me but now it is a must.
MSDN documentation is not easy at all.
It is poor in examples.
All the web sites that copy MS$ copy their samples too, it is difficult to see what we can really do.
If there were samples like the ones about fractals programmers would be numerous to try GDI+