Skip to content

Commit cb2658b

Browse files
committed
Added ImageBitmap and 2 functions of ImageCapture class
1 parent 0f6669a commit cb2658b

File tree

2 files changed

+74
-1
lines changed

2 files changed

+74
-1
lines changed

src/main/scala/org/scalajs/dom/experimental/mediastream/MediaStream.scala

+39-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ package org.scalajs.dom.experimental.mediastream
66
import scala.scalajs.js
77
import scala.scalajs.js.|
88
import scala.scalajs.js.annotation._
9-
import org.scalajs.dom.raw.{DOMException, Event, EventInit, EventTarget}
9+
import org.scalajs.dom.raw.{Blob, DOMException, Event, EventInit, EventTarget, ImageBitmap}
1010

1111
/**
1212
* The MediaStream
@@ -626,3 +626,41 @@ trait MediaTrackSupportedConstraints extends js.Object {
626626
var deviceId: js.UndefOr[Boolean] = js.undefined
627627
var groupId: js.UndefOr[Boolean] = js.undefined
628628
}
629+
630+
/**
631+
* The ImageCapture interface of the MediaStream Image Capture API provides methods
632+
* to enable the capture of images or photos from a camera or other photographic
633+
* device referenced through a valid MediaStreamTrack.
634+
*
635+
* MDN
636+
*/
637+
@js.native
638+
@JSGlobal
639+
class ImageCapture(
640+
init: js.UndefOr[MediaStreamTrack]
641+
) extends js.Object {
642+
643+
/**
644+
* Returns a reference to the MediaStreamTrack passed to the constructor.
645+
*
646+
* MDN
647+
*/
648+
val track: MediaStreamTrack = js.native
649+
650+
/**
651+
* Takes a single exposure using the video capture device sourcing a MediaStreamTrack and
652+
* returns a Promise that resolves with a Blob containing the data.
653+
*
654+
* MDN
655+
*/
656+
def takePhoto(): js.Promise[Blob] = js.native
657+
658+
/**
659+
* Takes a snapshot of the live video in a MediaStreamTrack, returning an ImageBitmap, if
660+
* successful.
661+
*
662+
* MDN
663+
*/
664+
def grabFrame(): js.Promise[ImageBitmap] = js.native
665+
666+
}

src/main/scala/org/scalajs/dom/raw/lib.scala

+35
Original file line numberDiff line numberDiff line change
@@ -6045,6 +6045,41 @@ class ImageData extends js.Object {
60456045
def height: Int = js.native
60466046
}
60476047

6048+
/**
6049+
* The ImageBitmap interface represents a bitmap image which can be drawn to a <canvas>
6050+
* without undue latency. It can be created from a variety of source objects using the
6051+
* createImageBitmap() factory method. ImageBitmap provides an asynchronous and resource
6052+
* efficient pathway to prepare textures for rendering in WebGL.
6053+
*
6054+
* MDN
6055+
*/
6056+
@js.native
6057+
@JSGlobal
6058+
class ImageBitmap extends js.Object {
6059+
6060+
/**
6061+
* Is an unsigned long representing the height, in CSS pixels, of the ImageBitmap.
6062+
*
6063+
* MDN
6064+
*/
6065+
def height: Long = js.native
6066+
6067+
/**
6068+
* Is an unsigned long representing the width, in CSS pixels, of the ImageBitmap.
6069+
*
6070+
* MDN
6071+
*/
6072+
def width: Long = js.native
6073+
6074+
/**
6075+
* Dispose of all graphical resources associated with an ImageBitmap.
6076+
*
6077+
* MDN
6078+
*/
6079+
def close(): Unit = js.native
6080+
6081+
}
6082+
60486083
/**
60496084
* A collection of nodes returned by Node.attributes (also potentially for
60506085
* DocumentType.entities, DocumentType.notations). NamedNodeMaps are not in any

0 commit comments

Comments
 (0)