Skip to content
3 changes: 2 additions & 1 deletion api-reports/2_12.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15651,9 +15651,10 @@ ImageBitmap[JT] def width: Double
ImageCapture[JC] def grabFrame(): js.Promise[ImageBitmap]
ImageCapture[JC] def takePhoto(): js.Promise[Blob]
ImageCapture[JC] val track: MediaStreamTrack
ImageData[JC] def data: js.typedarray.Uint8ClampedArray
ImageData[JC] def data: Uint8ClampedArray
ImageData[JC] def height: Int
ImageData[JC] def width: Int
ImageSettings[JT] var colorSpace: js.UndefOr[String]
InputEvent[JC] def bubbles: Boolean
InputEvent[JC] def cancelBubble: Boolean
InputEvent[JC] def cancelable: Boolean
Expand Down
3 changes: 2 additions & 1 deletion api-reports/2_13.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15651,9 +15651,10 @@ ImageBitmap[JT] def width: Double
ImageCapture[JC] def grabFrame(): js.Promise[ImageBitmap]
ImageCapture[JC] def takePhoto(): js.Promise[Blob]
ImageCapture[JC] val track: MediaStreamTrack
ImageData[JC] def data: js.typedarray.Uint8ClampedArray
ImageData[JC] def data: Uint8ClampedArray
ImageData[JC] def height: Int
ImageData[JC] def width: Int
ImageSettings[JT] var colorSpace: js.UndefOr[String]
InputEvent[JC] def bubbles: Boolean
InputEvent[JC] def cancelBubble: Boolean
InputEvent[JC] def cancelable: Boolean
Expand Down
52 changes: 51 additions & 1 deletion dom/src/main/scala/org/scalajs/dom/ImageData.scala
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ package org.scalajs.dom

import scala.scalajs.js
import scala.scalajs.js.annotation._
import scala.scalajs.js.typedarray.Uint8ClampedArray

/** The ImageData interface represents the underlying pixel data of an area of a <canvas> element. It is created
* using creators on the CanvasRenderingContext2D object associated with the canvas createImageData() and
Expand All @@ -17,14 +18,63 @@ import scala.scalajs.js.annotation._
@JSGlobal
class ImageData extends js.Object {

/** Create an ImageData instance from an array of pixel data and a width.
* @param data
* pixel data
* @param width
* width in pixels
*/
def this(data: Uint8ClampedArray, width: Int) = this()

/** Create an ImageData instance from an array of pixel data, width, and height.
* @param data
* pixel data
* @param width
* width in pixels
* @param height
* height in pixels
*/
def this(data: Uint8ClampedArray, width: Int, height: Int) = this()

/** Create a blank ImageData instance from specified width and height.
* @param width
* width in pixels
* @param height
* height in pixels
*/
def this(width: Int, height: Int) = this()

/** Create a blank ImageData instance from specified width, height, and settings object.
* @param width
* width in pixels
* @param height
* height in pixels
* @param settings
* image settings
*/
def this(width: Int, height: Int, settings: ImageSettings) = this()

/** Create a blank ImageData instance from specified pixel data, width, height, and settings object.
* @param data
* pixel data
* @param width
* width in pixels
* @param height
* height in pixels
* @param settings
* image settings
*/
def this(data: Uint8ClampedArray, width: Int, height: Int, settings: ImageSettings) = this()

/** Is an unsigned long representing the actual width, in pixels, of the ImageData. */
def width: Int = js.native

/** Is a Uint8ClampedArray representing a one-dimensional array containing the data in the RGBA order, with integer
* values between 0 and 255 (included).
*/
def data: js.typedarray.Uint8ClampedArray = js.native
def data: Uint8ClampedArray = js.native

/** Is an unsigned long representing the actual height, in pixels, of the ImageData. */
def height: Int = js.native

}
7 changes: 7 additions & 0 deletions dom/src/main/scala/org/scalajs/dom/ImageSettings.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package org.scalajs.dom

import scala.scalajs.js

trait ImageSettings extends js.Object {
var colorSpace: js.UndefOr[String] = js.undefined
}