Skip to content

Commit

Permalink
Images. Restore ImageBitmapSource [generated] (#2219)
Browse files Browse the repository at this point in the history
  • Loading branch information
turansky committed Mar 2, 2024
1 parent 6f810f3 commit cac5077
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

package web.canvas

import web.images.ImageBitmapSource

/**
* Union of:
* - `HTMLOrSVGImageElement`
Expand All @@ -11,4 +13,5 @@ package web.canvas
* - `OffscreenCanvas`
* - `VideoFrame`
*/
external interface CanvasImageSource
external interface CanvasImageSource :
ImageBitmapSource
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Automatically generated - do not modify!

@file:Suppress(
"NOTHING_TO_INLINE",
)

package web.images

import web.blob.Blob

/**
* Union of:
* - `CanvasImageSource`
* - `Blob`
* - `ImageData`
*/
external interface ImageBitmapSource

inline fun Blob.asImageBitmapSource(): ImageBitmapSource =
unsafeCast<ImageBitmapSource>()

inline fun ImageBitmapSource.asBlobOrNull(): Blob? =
asDynamic() as? Blob
3 changes: 2 additions & 1 deletion kotlin-browser/src/jsMain/generated/web/images/ImageData.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ external class ImageData(
sw: Int,
sh: Int,
settings: ImageDataSettings = definedExternally,
) : TexImageSource {
) : ImageBitmapSource,
TexImageSource {
constructor(
data: Uint8ClampedArray,
sw: Int,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,47 +3,17 @@
package web.images

import js.promise.Promise
import web.blob.Blob
import web.canvas.CanvasImageSource

/**
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/createImageBitmap)
*/
external fun createImageBitmap(
image: CanvasImageSource,
image: ImageBitmapSource,
options: ImageBitmapOptions? = definedExternally,
): Promise<ImageBitmap>

external fun createImageBitmap(
image: Blob,
options: ImageBitmapOptions? = definedExternally,
): Promise<ImageBitmap>

external fun createImageBitmap(
image: ImageData,
options: ImageBitmapOptions? = definedExternally,
): Promise<ImageBitmap>

external fun createImageBitmap(
image: CanvasImageSource,
sx: Int,
sy: Int,
sw: Int,
sh: Int,
options: ImageBitmapOptions? = definedExternally,
): Promise<ImageBitmap>

external fun createImageBitmap(
image: Blob,
sx: Int,
sy: Int,
sw: Int,
sh: Int,
options: ImageBitmapOptions? = definedExternally,
): Promise<ImageBitmap>

external fun createImageBitmap(
image: ImageData,
image: ImageBitmapSource,
sx: Int,
sy: Int,
sw: Int,
Expand Down

0 comments on commit cac5077

Please sign in to comment.