Internal Documentation - iseahound/ImagePut GitHub Wiki

Calling ImagePut("file", "cats.jpg") is the same as calling ImagePutFile("cats.jpg").

There are 3 steps:

  1. Calling ImageType on the input image.
  2. Passing the type and input image to ToBitmap.
  3. Passing the Bitmap and any optional arguments to BitmapToCoimage.

Example:

#include ImagePut.ahk
ImagePut.gdiplusStartup()                                   ; Allow handling of GDI+ bitmaps.
image_type := ImagePut.ImageType("cats.jpg")                ; Get the image_type as "file".
pBitmap := ImagePut.ToBitmap(image_type, "cats.jpg")        ; Convert to pixel data.
hwnd := ImagePut.BitmapToCoimage("window", pBitmap, "Cat!") ; Show the image on-screen with a caption.

DontVerifyImageType

Dereferences objects like {file: "cats.jpg"} to "cats.jpg".

ImageType

Where all the magic happens. Calling ImagePut.ImageType("cats.jpg") will retrieve the windows image data type.

ToBitmap(type, image)

This function converts an image into a bitmap. Dispatches to all functions beginning with from_XXX.

pBitmap := ImagePut.ToBitmap("file", "cats.jpg")

BitmapToCoimage(cotype, pBitmap, p1, p2)

Converts a bitmap into any supported image type. Dispatches to all functions beginning with put_XXX.

ImagePut.BitmapToCoimage("window", pBitmap)

ToStream(type, image)

This function converts an image into a stream. Dispatches to all functions beginning with get_XXX.

pStream := ImagePut.ToStream("file", "cats.jpg")

StreamToCoimage(cotype, pStream, p1, p2)

Converts a stream into any supported image type. Dispatches to all functions beginning with set_XXX.

filepath := ImagePut.StreamToCoimage("file", pStream)

from_XXX

These functions always convert to a pBitmap.

; Get the current wallpaper as a bitmap.
pBitmap := ImagePut.from_wallpaper()

; Get the current cursor as a bitmap.
pBitmap := ImagePut.from_cursor()

; Get a web image as a bitmap.
pBitmap := ImagePut.from_url("https://i.imgur.com/PBy1WBT.png")

put_XXX

These functions always convert from a bitmap into some type.

; Set the current wallpaper.
ImagePut.put_wallpaper(pBitmap)

; Set the cursor.
ImagePut.put_cursor(pBitmap)

get_XXX

These functions always convert to a pStream.

set_XXX

These functions always convert from a stream into some type.

Streams vs. MemoryStreams

SHCreateMemStream creates a memorystream. CreateStreamOnHGlobal creates a stream. The difference between the two outputs is that only GetHGlobalFromStream is supported by streams. Therefore to maximize compatibility, all set_XXX functions will create streams without the shlwapi functions. And all get_XXX functions will read both streams and memorystreams by never calling GetHGlobalFromStream.