TypeDoc
Utils Image

vcapi-workers / Exports / utils/image

Module: utils/image

画像を扱うユーティリティ。おもに image downloader 向けレスポンスを想定 この関数たちを使うと JSON を PNG画像に埋め込んで返せる

Table of contents

Variables

Functions

Variables

contentTypePng

Const contentTypePng: Object

Type declaration

NameType
Content-Type"image/png"

Defined in

src/utils/image.ts:15 (opens in a new tab)


emptyPng

Const emptyPng: Uint8Array

4x4 sRGB 白単色 PNG

Defined in

src/utils/image.ts:12 (opens in a new tab)

Functions

bytes2Image

bytes2Image(buffer): ImageData

バイト列を ImageData にします

Remarks

先頭に長さを 32bit int で格納したのちバイト列をそのまま詰めた画像になります

See

png

Parameters

NameType
bufferUint8Array

Returns

ImageData

そのまま png 関数で使う、{ width, height, data }

Defined in

src/utils/image.ts:49 (opens in a new tab)


emptyImage

emptyImage(c): Response

image downloader 向けの c.text('')

Parameters

NameType
cContext<any, any, {}>

Returns

Response

Defined in

src/utils/image.ts:18 (opens in a new tab)


json2Image

json2Image(json): ImageData

json オブジェクトを ImageData にします

Remarks

先頭に長さを 32bit int で格納したのちバイト列をそのまま詰めた画像になります

See

png

Parameters

NameType
jsonobject

Returns

ImageData

そのまま png 関数で使う、{ width, height, data }

Defined in

src/utils/image.ts:39 (opens in a new tab)


png

png(c, png): Response

PNG画像のレスポンスを返す

Remarks

普通は json2Imagebytes2Image で生成した引数を渡して使うはず

width, height は 256 以下推奨

Parameters

NameTypeDescription
cContext<any, any, {}>-
pngImageDataImageData は { width, height, data }

Returns

Response

Defined in

src/utils/image.ts:29 (opens in a new tab)