<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.whatwg.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Xidachen</id>
	<title>WHATWG Wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.whatwg.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Xidachen"/>
	<link rel="alternate" type="text/html" href="https://wiki.whatwg.org/wiki/Special:Contributions/Xidachen"/>
	<updated>2026-04-04T01:40:50Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.39.3</generator>
	<entry>
		<id>https://wiki.whatwg.org/index.php?title=OffscreenCanvas&amp;diff=10092</id>
		<title>OffscreenCanvas</title>
		<link rel="alternate" type="text/html" href="https://wiki.whatwg.org/index.php?title=OffscreenCanvas&amp;diff=10092"/>
		<updated>2016-09-07T15:36:20Z</updated>

		<summary type="html">&lt;p&gt;Xidachen: /* Web IDL */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;:&#039;&#039;Provides more control over how canvases are rendered. This is a follow-on to the [[WorkerCanvas]] proposal and will be merged once agreement is reached.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== Use Case Description ==&lt;br /&gt;
&lt;br /&gt;
Feedback from web application authors using canvases have shown the need for the following controls:&lt;br /&gt;
&lt;br /&gt;
* (From ShaderToy, Sketchfab, Verold): need to be able to render to multiple regions on the page efficiently using a single canvas context. 3D model warehouse sites desire to show multiple live interactive models on the page, but creating multiple WebGL contexts per page is too inefficient. A single context should be able to render to multiple regions on the page.&lt;br /&gt;
* (From Google Maps): need to be able to render WebGL from a worker, transfer the rendered image to the main thread without making any copy of it, and composite it with other HTML on the page, guaranteeing that the updates are all seen in the same rendered frame.&lt;br /&gt;
* (From Mozilla and partners using Emscripten and asm.js): need to be able to render WebGL entirely asynchronously from a worker, displaying the results in a canvas owned by the main thread, without any synchronization with the main thread. In this mode, the entire application runs in the worker. The main thread only receives input events and sends them to the worker for processing.&lt;br /&gt;
* (From adopters of the Push API): need to be able to dynamically create images to use as notification icons, such as compositing avatars, or adding an unread count&lt;br /&gt;
* (From the Google Docs team): need to be able to layout and render text from a worker using CanvasRenderingContext2D and display those results on the main thread.&lt;br /&gt;
* (From the Google Slides team): want to layout and render the slide thumbnails from a worker. During initial load and heavy collaboration these update frequently, and currently cause slowdowns on the main thread.&lt;br /&gt;
&lt;br /&gt;
=== Current Limitations ===&lt;br /&gt;
&lt;br /&gt;
* [https://html.spec.whatwg.org/multipage/scripting.html#proxying-canvases-to-workers CanvasProxy] does not provide sufficient control to allow synchronization between workers&#039; rendering and DOM updates on the main thread. Keeping this rendering in sync is a requirement from Google&#039;s Maps team.&lt;br /&gt;
* [[CanvasInWorkers]] does not allow a worker to render directly into a canvas on the main thread without running code on the main thread. Allowing completely unsynchronized rendering is a requirement from Mozilla and users of Emscripten such as Epic Games and Unity, in which the desire is to execute all of the game&#039;s rendering on a worker thread.&lt;br /&gt;
* [[WorkerCanvas]] mostly addresses these two use cases, but some implementers objected to the mechanism for displaying the rendering results in image elements. The specific objection was that image elements already have complex internal state (for example, the management of the image&#039;s &amp;quot;loaded&amp;quot; state), and this would make it more complex. It also did not precisely address the use case of producing new frames both on the main thread and in workers.&lt;br /&gt;
&lt;br /&gt;
=== Current Usage and Workarounds ===&lt;br /&gt;
&lt;br /&gt;
[https://blog.mozilla.org/research/2014/07/22/webgl-in-web-workers-today-and-faster-than-expected/ WebGL in Web Workers] details some work attempted in the Emscripten toolchain to address the lack of WebGL in workers. Due to the high volume of calls and large amount of data that is transferred to the graphics card in a typical high-end WebGL application, this approach is not sustainable. It&#039;s necessary for workers to be able to call the WebGL API directly, and present those results to the screen in a manner that does not introduce any copies of the rendering results.&lt;br /&gt;
&lt;br /&gt;
=== Benefits ===&lt;br /&gt;
&lt;br /&gt;
Making canvas rendering contexts available to workers will increase parallelism in web applications, leading to increased performance on multi-core systems.&lt;br /&gt;
&lt;br /&gt;
=== Requests for this Feature ===&lt;br /&gt;
&lt;br /&gt;
See the abovementioned use cases:&lt;br /&gt;
&lt;br /&gt;
* Google&#039;s Maps team&lt;br /&gt;
* Emscripten users such as Epic Games and Unity&lt;br /&gt;
* Many others&lt;br /&gt;
&lt;br /&gt;
== Web IDL ==&lt;br /&gt;
&lt;br /&gt;
 typedef (OffscreenCanvasRenderingContext2D or&lt;br /&gt;
          WebGLRenderingContext or&lt;br /&gt;
          WebGL2RenderingContext) OffscreenRenderingContext;&lt;br /&gt;
 &lt;br /&gt;
 [Constructor(unsigned long width, unsigned long height),&lt;br /&gt;
  Exposed=(Window,Worker)]&lt;br /&gt;
 interface OffscreenCanvas {&lt;br /&gt;
   attribute unsigned long width;&lt;br /&gt;
   attribute unsigned long height;&lt;br /&gt;
   OffscreenRenderingContext? getContext(DOMString contextId, any... arguments); &lt;br /&gt;
 &lt;br /&gt;
   // OffscreenCanvas, like HTMLCanvasElement, maintains an origin-clean flag.&lt;br /&gt;
   // ImageBitmaps created by calling this method also have an&lt;br /&gt;
   // origin-clean flag which is set to the value of the OffscreenCanvas&#039;s&lt;br /&gt;
   // flag at the time of their construction. Uses of the ImageBitmap&lt;br /&gt;
   // in other APIs, such as CanvasRenderingContext2D or&lt;br /&gt;
   // WebGLRenderingContext, propagate this flag like other&lt;br /&gt;
   // CanvasImageSource types do, such as HTMLImageElement.&lt;br /&gt;
   ImageBitmap transferToImageBitmap();&lt;br /&gt;
 &lt;br /&gt;
   // Throws a SecurityError if the OffscreenCanvas&#039;s origin-clean flag&lt;br /&gt;
   // is set to false.&lt;br /&gt;
   Promise&amp;lt;Blob&amp;gt; convertToBlob(optional ImageEncodeOptions options);   &lt;br /&gt;
 };&lt;br /&gt;
 &lt;br /&gt;
 dictionary ImageEncodeOptions {&lt;br /&gt;
   DOMString type = &amp;quot;image/png&amp;quot;;&lt;br /&gt;
   unrestricted double quality = 1.0; // Defaults to 1.0 if value is outside 0:1 range&lt;br /&gt;
 };&lt;br /&gt;
 &lt;br /&gt;
 OffscreenCanvas implements Transferable;&lt;br /&gt;
 &lt;br /&gt;
 partial interface HTMLCanvasElement {&lt;br /&gt;
   OffscreenCanvas transferControlToOffscreen();&lt;br /&gt;
 };&lt;br /&gt;
 &lt;br /&gt;
 typedef (HTMLOrSVGImageElement or&lt;br /&gt;
          HTMLVideoElement or&lt;br /&gt;
          HTMLCanvasElement or&lt;br /&gt;
          ImageBitmap or&lt;br /&gt;
          OffscreenCanvas) CanvasImageSource;&lt;br /&gt;
 &lt;br /&gt;
 typedef (CanvasImageSource or&lt;br /&gt;
          Blob or&lt;br /&gt;
          ImageData or&lt;br /&gt;
          OffscreenCanvas) ImageBitmapSource;&lt;br /&gt;
 &lt;br /&gt;
 [Exposed=Window, Worker]&lt;br /&gt;
 interface OffscreenCanvasRenderingContext2D {&lt;br /&gt;
   // commit() can only be used when HTMLCanvasElement has transferred Control&lt;br /&gt;
   // to OffscreenCanvas. Otherwise, an InvalidStateError will be thrown.&lt;br /&gt;
   // commit() can be invoked on main thread or worker thread. When it is invoked,&lt;br /&gt;
   // it is expected to see the image drawn to OffscreenCanvasRenderingContext2D &lt;br /&gt;
   // be displayed in the associated HTMLCanvasElement.&lt;br /&gt;
   void commit();&lt;br /&gt;
   // back-reference to the canvas&lt;br /&gt;
   readonly attribute OffscreenCanvas canvas;&lt;br /&gt;
 };&lt;br /&gt;
 OffscreenCanvasRenderingContext2D implements CanvasState;&lt;br /&gt;
 OffscreenCanvasRenderingContext2D implements CanvasTransform;&lt;br /&gt;
 OffscreenCanvasRenderingContext2D implements CanvasCompositing;&lt;br /&gt;
 OffscreenCanvasRenderingContext2D implements CanvasImageSmoothing;&lt;br /&gt;
 OffscreenCanvasRenderingContext2D implements CanvasFillStrokeStyles;&lt;br /&gt;
 OffscreenCanvasRenderingContext2D implements CanvasShadowStyles;&lt;br /&gt;
 // Reference filters (e.g. &#039;url()&#039;) are not expected to work in Workers&lt;br /&gt;
 OffscreenCanvasRenderingContext2D implements CanvasFilters;&lt;br /&gt;
 OffscreenCanvasRenderingContext2D implements CanvasRect;&lt;br /&gt;
 OffscreenCanvasRenderingContext2D implements CanvasDrawPath;&lt;br /&gt;
 // Text support in workers poses very difficult technical challenges.&lt;br /&gt;
 // Open issue: should we forgo text support in OffscreenCanvas v1?&lt;br /&gt;
 OffscreenCanvasRenderingContext2D implements CanvasText;&lt;br /&gt;
 OffscreenCanvasRenderingContext2D implements CanvasDrawImage;&lt;br /&gt;
 OffscreenCanvasRenderingContext2D implements CanvasImageData;&lt;br /&gt;
 OffscreenCanvasRenderingContext2D implements CanvasPathDrawingStyles;&lt;br /&gt;
 OffscreenCanvasRenderingContext2D implements CanvasTextDrawingStyles;&lt;br /&gt;
 OffscreenCanvasRenderingContext2D implements CanvasPath; &lt;br /&gt;
 &lt;br /&gt;
 [Exposed=Window, Worker]&lt;br /&gt;
 Partial interface CanvasPattern {&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 [Exposed=Window, Worker]&lt;br /&gt;
 partial interface CanvasGradient {&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 partial interface WebGLRenderingContextBase {&lt;br /&gt;
   // back-reference to the canvas&lt;br /&gt;
   readonly attribute (HTMLCanvasElement or OffscreenCanvas) canvas;&lt;br /&gt;
 &lt;br /&gt;
   // If this context is associated with an OffscreenCanvas that was&lt;br /&gt;
   // created by HTMLCanvasElement&#039;s transferControlToOffscreen method,&lt;br /&gt;
   // causes this context&#039;s current rendering results to be pushed&lt;br /&gt;
   // to that canvas element. This has the same effect as returning&lt;br /&gt;
   // control to the main loop in a single-threaded application. Otherwise,&lt;br /&gt;
   // an InvalidStateError will be thrown.&lt;br /&gt;
   void commit();&lt;br /&gt;
 };&lt;br /&gt;
&lt;br /&gt;
== Proposed Solutions ==&lt;br /&gt;
&lt;br /&gt;
=== This Solution ===&lt;br /&gt;
&lt;br /&gt;
This proposed API can be used in several ways to satisfy the use cases described above:&lt;br /&gt;
&lt;br /&gt;
* It supports zero-copy transfer of canvases&#039; rendering results between threads, for example from a worker to the main thread. In this model, the main thread controls when to display new frames produced by the worker, so synchronization with other DOM updates is achieved.&lt;br /&gt;
&lt;br /&gt;
* It supports fully asynchronous rendering by a worker into a canvas displayed on the main thread. This satisfies certain Emscripten developers&#039; full-screen use cases.&lt;br /&gt;
&lt;br /&gt;
* It supports using a single WebGLRenderingContext or Canvas2DRenderingContext to efficiently render into multiple regions on the web page.&lt;br /&gt;
&lt;br /&gt;
* It introduces ImageBitmapRenderingContext, a new canvas context type whose sole purpose is to efficiently display ImageBitmaps. This supersedes the [[WorkerCanvas]] proposal&#039;s use of HTMLImageElement for this purpose.&lt;br /&gt;
&lt;br /&gt;
* It supports asynchronous encoding of OffscreenCanvases&#039; rendering results into Blobs which can be consumed by various other web platform APIs.&lt;br /&gt;
&lt;br /&gt;
==== Processing Model ====&lt;br /&gt;
&lt;br /&gt;
This proposal introduces two primary processing models. The first involves &#039;&#039;synchronous&#039;&#039; display of new frames produced by the OffscreenCanvas. The application generates new frames using the RenderingContext obtained from the OffscreenCanvas. When the application is finished rendering each new frame, it calls transferToImageBitmap to &amp;quot;tear off&amp;quot; the most recently rendered image from the OffscreenCanvas -- like a Post-It note. The resulting ImageBitmap can then be used in any API receiving that data type; notably, it can be displayed in a second canvas without introducing a copy. An ImageBitmapRenderingContext is obtained from the second canvas by calling &amp;lt;code&amp;gt;getContext(&#039;bitmaprenderer&#039;)&amp;lt;/code&amp;gt;. Each frame is displayed in the second canvas using the &amp;lt;code&amp;gt;transferImageBitmap&amp;lt;/code&amp;gt; method on this rendering context. Note that the threads producing and consuming the frames may be the same, or they may be different. Note also that a single OffscreenCanvas may transfer frames into an arbitrary number of other ImageBitmapRenderingContexts.&lt;br /&gt;
&lt;br /&gt;
The second processing model involves &#039;&#039;asynchronous&#039;&#039; display of new frames produced by the OffscreenCanvas. The main thread instantiates an HTMLCanvasElement and calls &amp;lt;code&amp;gt;transferControlToOffscreeen&amp;lt;/code&amp;gt;. &amp;lt;code&amp;gt;getContext&amp;lt;/code&amp;gt; is used to obtain a rendering context for that OffscreenCanvas, either on the main thread, or on a worker. The application calls &amp;lt;code&amp;gt;commit&amp;lt;/code&amp;gt; against that rendering context in order to push frames to the original HTMLCanvasElement. In this rendering model, it is not defined when those frames become visible in the original canvas element. However, if the following situations apply:&lt;br /&gt;
&lt;br /&gt;
* It is a worker thread which is calling commit(), and&lt;br /&gt;
* The worker is calling commit() repeatedly against exactly one rendering context&lt;br /&gt;
&lt;br /&gt;
then it is required that the user agent synchronize the calls to commit() to the vsync interval. Calls to commit() conceptually enqueue frames for display, and after an implementation-defined number of frames have been enqueued, further calls to commit() will block until earlier frames have been presented to the screen. (This requirement allows porting of applications which drive their own main loop rather than using an event-driven loop.)&lt;br /&gt;
&lt;br /&gt;
==== Limitations ==== &lt;br /&gt;
&lt;br /&gt;
* A known good way to drive an animation loop from a worker is needed. requestAnimationFrame or a similar API needs to be defined on worker threads.&lt;br /&gt;
* Some parts of the CanvasRenderingContext2D interface shall not be supported due OffscreenCanvas objects having no relation to the DOM or Frame: HitRegions, scrollPathIntoView, drawFocusIfNeeded.&lt;br /&gt;
* Due to technical challenges, some implementors [https://bugzilla.mozilla.org/show_bug.cgi?id=801176#c29 (Google and Mozilla)] have expressed a desire to ship without initially supporting text rendering in 2D contexts. Open Issue: Should text support be formally excluded from the specification until implementors are prepared to ship it (or until a more feasible API is designed)?&lt;br /&gt;
&lt;br /&gt;
==== Implementation ==== &lt;br /&gt;
&lt;br /&gt;
This proposal has been vetted by developers of Apple&#039;s Safari, Google&#039;s Chrome, Microsoft&#039;s Internet Explorer, and Mozilla&#039;s Firefox browsers. All vendors agreed upon the basic form of the API, so it is likely it will be implemented widely and compatibly.&lt;br /&gt;
&lt;br /&gt;
==== Adoption ==== &lt;br /&gt;
&lt;br /&gt;
Web page authors have demanded increased parallelism support from the web platform for multiple years. If support for multithreaded rendering is added, it is likely it will be rapidly adopted.&lt;br /&gt;
&lt;br /&gt;
==== Example code ====&lt;br /&gt;
&lt;br /&gt;
Jeff Gilbert from Mozilla has crafted some example code utilizing this API:&lt;br /&gt;
&lt;br /&gt;
* [https://github.com/jdashg/snippets/tree/master/webgl-from-worker Rendering WebGL from a worker using the commit() API]&lt;br /&gt;
* [https://github.com/jdashg/snippets/blob/master/webgl-one-to-many/index.html Using one WebGL context to render to many Canvas elements]&lt;br /&gt;
&lt;br /&gt;
[[Category:Proposals]]&lt;/div&gt;</summary>
		<author><name>Xidachen</name></author>
	</entry>
	<entry>
		<id>https://wiki.whatwg.org/index.php?title=ImageBitmap_Options&amp;diff=10036</id>
		<title>ImageBitmap Options</title>
		<link rel="alternate" type="text/html" href="https://wiki.whatwg.org/index.php?title=ImageBitmap_Options&amp;diff=10036"/>
		<updated>2016-02-10T20:42:37Z</updated>

		<summary type="html">&lt;p&gt;Xidachen: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
This page is a Work in Progress&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Problem to be solved&#039;&#039;&#039;: Loading and preparing image resources for rendering to 2D canvas contexts and WebGL contexts is often inefficient using existing APIs.&lt;br /&gt;
&lt;br /&gt;
== Use Case Description ==&lt;br /&gt;
:WebGL applications often use image media for transferring non-image data (illumination maps, vector maps, etc.) For such applications the image data must usually be decoded without colorspace conversions and without alpha premultiplications.&lt;br /&gt;
&lt;br /&gt;
=== Current Usage and Workarounds ===&lt;br /&gt;
&lt;br /&gt;
:Currently, there are several ways to apply arbitrary transformations on the client side, many of which involve intermediate copies of the image data. Some solutions involve DataURLs, temporary canvases, or direct manipulation of image data arrays, which are inefficient. Preparing the resources asynchronously also presents an additional challenge to the web developer.&lt;br /&gt;
&lt;br /&gt;
:WebGL applications can request that colorspace conversions be skipped at texture upload time by specifying pixel storage parameters, but this currently causes a synchronous image decode, because it is not known in advance that the image will need to be decoded in a special way. This latency is a significant problem for applications that upload many images to the GPU, such as Google Maps.&lt;br /&gt;
&lt;br /&gt;
:ImageBitmap offers an opportunity to provide exactly the desired image decoding options when the image is fetched, so that when the ImageBitmap is ready, it is in exactly the desired form for upload to the GPU.&lt;br /&gt;
&lt;br /&gt;
=== Benefits ===&lt;br /&gt;
&lt;br /&gt;
:With the right API support, image resources can be prepared asynchronously and/or in advance to avoid rendering latency issues. Furthermore, the preparation steps could be performed by native code, and in many case they can be integrated directly into the image decoding step without any additional memory consumption and little or no additional computational burden.&lt;br /&gt;
&lt;br /&gt;
=== Requests for this Feature ===&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;cite&amp;gt;[https://lists.w3.org/Archives/Public/public-whatwg-archive/2013Jun/0114.html June 2013 whatwg thread]&amp;lt;/cite&amp;gt;&lt;br /&gt;
* &amp;lt;cite&amp;gt;[https://lists.w3.org/Archives/Public/public-whatwg-archive/2013Jul/0075.html July 2013 whatwg thread]&amp;lt;/cite&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Web IDL ==&lt;br /&gt;
&lt;br /&gt;
 enum ImageOrientation { &amp;quot;none&amp;quot;, &amp;quot;flipY&amp;quot; };&lt;br /&gt;
 enum PremultiplyAlpha { &amp;quot;none&amp;quot;, &amp;quot;premultiply&amp;quot;, &amp;quot;default&amp;quot; };&lt;br /&gt;
 enum ColorspaceConversion { &amp;quot;none&amp;quot;, &amp;quot;default&amp;quot; };&lt;br /&gt;
 dictionary ImageBitmapOptions {&lt;br /&gt;
   ImageOrientation imageOrientation = &amp;quot;none&amp;quot;;&lt;br /&gt;
   PremultiplyAlpha premultiplyAlpha = &amp;quot;default&amp;quot;;&lt;br /&gt;
   ColorspaceConversion colorspaceConversion = &amp;quot;default&amp;quot;;&lt;br /&gt;
 };&lt;br /&gt;
 &lt;br /&gt;
 partial interface ImageBitmapFactories {&lt;br /&gt;
   Promise&amp;lt;ImageBitmap&amp;gt; createImageBitmap(ImageBitmapSource image, optional ImageBitmapOptions options);&lt;br /&gt;
   Promise&amp;lt;ImageBitmap&amp;gt; createImageBitmap(ImageBitmapSource image, long sx, long sy, long sw, long sh, optional ImageBitmapOptions options);&lt;br /&gt;
 };&lt;br /&gt;
&lt;br /&gt;
* Note: This IDL reflects the &amp;quot;Strongly desired options&amp;quot; below.&lt;br /&gt;
&lt;br /&gt;
== Proposed Solutions ==&lt;br /&gt;
&lt;br /&gt;
=== ImageBitmap Construction Options ===&lt;br /&gt;
&lt;br /&gt;
:Add an optional &#039;&#039;options&#039;&#039; argument to createImageBitmap to specify image treatments to be applied when creating the ImageBitmap object.&lt;br /&gt;
&lt;br /&gt;
==== Strongly desired options ====&lt;br /&gt;
&lt;br /&gt;
* enum imageOrientation, default = &#039;none&#039; &amp;lt;blockquote&amp;gt;&amp;lt;p&amp;gt;&#039;none&#039;: Do not change orientation.&amp;lt;/p&amp;gt;&amp;lt;p&amp;gt;&#039;flipY&#039;: Flip image vertically, disregarding image orientation meta data (EXIF or other), if any.&amp;lt;/p&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
* enum colorspaceConversion, default = &#039;default&#039; &amp;lt;blockquote&amp;gt;&amp;lt;p&amp;gt;&#039;none&#039;: The ImageBitmap must be created by decoding the source image media without performing any colorspace conversions. This means that the image decoding algorithm must ignore color profile meta-data embedded in the image source as well as the display device color profile.  colorspaceConversion only applies when creating ImageBitmaps from bitmap media data (i.e. blobs and image elements with non-vector images)&amp;lt;/p&amp;gt; &amp;lt;p&amp;gt;&#039;default&#039;: Implementation-specific behavior, possibly optimized for the implementation&#039;s graphics framework.&amp;lt;/p&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
* enum premultiplyAlpha, default = &#039;default&#039; &amp;lt;blockquote&amp;gt;&amp;lt;p&amp;gt;&#039;none&#039;: Image sources that have raw image data that is not premultiplied by alpha will be left untouched and image sources that are premultiplied by alpha will have their color components divided by alpha.&amp;lt;/p&amp;gt;&amp;lt;p&amp;gt;&#039;premultiply&#039;: Image sources that have raw image data that is not premultiplied by alpha will have their color components multiplied by alpha and image sources that are premultiplied by alpha will be left untouched.&amp;lt;/p&amp;gt;&amp;lt;p&amp;gt;&#039;default&#039;: Implementation-specific behavior, possibly optimized for the implementation&#039;s graphics framework.&amp;lt;/p&amp;gt;&amp;lt;p&amp;gt;When premultiplyAlpha is set to &#039;none&#039;, the division by alpha may result in loss of precision, which must be avoided whenever possible. For example, if the image source is a blob or an image element, the decoded image may already be available in premultipled form. Rather than divide the already decoded data, the user agent must re-decode the image without premultiplying, thus ensuring that the ImageBitmap is delivered with the highest quality data.&amp;lt;/p&amp;gt;&amp;lt;p&amp;gt;Image sources that do not have an alpha channel are not affected by this option.&amp;lt;/p&amp;gt;&amp;lt;p&amp;gt;Caution: 2D Canvases may or may not be stored in premultipled form, depending on the implementation.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Other potentially useful options ====&lt;br /&gt;
* enum imageOrientation, &#039;topLeft&#039; and &#039;bottomLeft&#039; &amp;lt;blockquote&amp;gt;&amp;lt;p&amp;gt;&#039;topLeft&#039;:  identify visual orientation from image media meta data and re-order data so top-down, left-to-right processing for display results in correct visual orientation. If the image source is an ImageBitmap, the image data will be flipped vertically if and only if the source was created with bottomLeft orientation. If the image source holds no orientation information, the image orientation is not changed.&amp;lt;/p&amp;gt;&amp;lt;p&amp;gt;&#039;bottomLeft&#039;: identify visual orientation from image media meta data and re-order data so bottom-up, left-to-right processing for display results in correct visual orientation. If the image source is an ImageBitmap, the image data will be flipped vertically if and only if the source was created with topLeft orientation. If the image source holds no orientation information, the image is flipped vertically.&amp;lt;/p&amp;gt;&amp;lt;blockquote&amp;gt; &lt;br /&gt;
* DOMString? crossOrigin: The crossOrigin option is a [[https://html.spec.whatwg.org/multipage/infrastructure.html#cors-settings-attribute CORS settings attribute]]. It is consulted when [[ImageBitmap Constructor taking URL|constructing an ImageBitmap from the URL of an image]]. Because ImageBitmaps can only be constructed from same-origin resources, in order to construct an ImageBitmap from the URL of a cross-origin image resource, the crossOrigin option must be specified, and the server must grant the request. Otherwise the Promise returned from createImageBitmap will be rejected. &amp;lt;blockquote&amp;gt;&amp;lt;p&amp;gt;Note: this is a convenience feature. At this moment, using the process of XHR-&amp;gt;Blob-&amp;gt;ImageBitmap will achieve the same goal.&amp;lt;/p&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
* resizedWidth, resizedHeight: dimension to which the image should be resized. Could also be expressed using scale factors&lt;br /&gt;
* resizeFilter: filtering method used for scaling the image (pixelated, low quality, high quality, etc.)&lt;br /&gt;
* frameIndex: for creating an image bitmap from multi-frame image media&lt;br /&gt;
* flipX: like flipY but horizontal&lt;br /&gt;
* colorspace: to decode images to a colorspace other than the device colorspace (sRGB, Adobe RGB, YUV, YCbCr, etc.)&lt;br /&gt;
* custom color tranforms: color matrix, 3D Look up tables, per component look up tables, bias, gain, ... &lt;br /&gt;
&lt;br /&gt;
==== Processing Model ====&lt;br /&gt;
: These options affect the internal color representation used to store the ImageBitmap&#039;s bitmap data. The only observable effects would be on color fidelity. There would be no re-interpretation of color values. This is important because treating unpremultiplied colors as premultiplied is evil. For example, in blink&#039;s implementation, setting both options to &#039;none&#039; would have no side-effects on the graphical results of CanvasRenderingContext2D.drawImage(). The only difference would be that the color-space conversion and the multiplication by alpha would be deferred to drawImage(), instead of being applied during ImageBitmap creation. The usefulness of &#039;none&#039; is strictly for preventing losses in precision and gamut that may result from dividing by alpha and/or reversing the default color-space conversion when using APIs that would require it (WebGL&#039;s UNPACK_PREMULTIPLY_ALPHA_WEBGL and UNPACK_COLORSPACE_CONVERSION_WEBGL pixel storage parameters)&lt;br /&gt;
&lt;br /&gt;
==== Limitations ==== &lt;br /&gt;
: TBD &#039;&#039;Cases not covered by this solution in relation to the problem description; other problems with this solution, if any.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
==== Implementation ==== &lt;br /&gt;
: TBD &#039;&#039;Description of how and why browser vendors would take advantage of this feature.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
==== Adoption ==== &lt;br /&gt;
* Easier to develop asychronous image resource loading and preparation&lt;br /&gt;
* Better performance that what can be implemented using current APIs&lt;br /&gt;
* Applications can rely on the browser resource management facilities for caching decoded image data with the desired options baked-in and for evicting pre-decoded resources in low memory conditions to avoid out-of-memory crashes.&lt;br /&gt;
&lt;br /&gt;
==== See Also ====&lt;br /&gt;
&lt;br /&gt;
Related is the [[ImageBitmap Constructor taking URL]].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Proposals]]&lt;/div&gt;</summary>
		<author><name>Xidachen</name></author>
	</entry>
	<entry>
		<id>https://wiki.whatwg.org/index.php?title=ImageBitmap_Options&amp;diff=10035</id>
		<title>ImageBitmap Options</title>
		<link rel="alternate" type="text/html" href="https://wiki.whatwg.org/index.php?title=ImageBitmap_Options&amp;diff=10035"/>
		<updated>2016-02-10T20:12:21Z</updated>

		<summary type="html">&lt;p&gt;Xidachen: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
This page is a Work in Progress&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Problem to be solved&#039;&#039;&#039;: Loading and preparing image resources for rendering to 2D canvas contexts and WebGL contexts is often inefficient using existing APIs.&lt;br /&gt;
&lt;br /&gt;
== Use Case Description ==&lt;br /&gt;
:WebGL applications often use image media for transferring non-image data (illumination maps, vector maps, etc.) For such applications the image data must usually be decoded without colorspace conversions and without alpha premultiplications.&lt;br /&gt;
&lt;br /&gt;
=== Current Usage and Workarounds ===&lt;br /&gt;
&lt;br /&gt;
:Currently, there are several ways to apply arbitrary transformations on the client side, many of which involve intermediate copies of the image data. Some solutions involve DataURLs, temporary canvases, or direct manipulation of image data arrays, which are inefficient. Preparing the resources asynchronously also presents an additional challenge to the web developer.&lt;br /&gt;
&lt;br /&gt;
:WebGL applications can request that colorspace conversions be skipped at texture upload time by specifying pixel storage parameters, but this currently causes a synchronous image decode, because it is not known in advance that the image will need to be decoded in a special way. This latency is a significant problem for applications that upload many images to the GPU, such as Google Maps.&lt;br /&gt;
&lt;br /&gt;
:ImageBitmap offers an opportunity to provide exactly the desired image decoding options when the image is fetched, so that when the ImageBitmap is ready, it is in exactly the desired form for upload to the GPU.&lt;br /&gt;
&lt;br /&gt;
=== Benefits ===&lt;br /&gt;
&lt;br /&gt;
:With the right API support, image resources can be prepared asynchronously and/or in advance to avoid rendering latency issues. Furthermore, the preparation steps could be performed by native code, and in many case they can be integrated directly into the image decoding step without any additional memory consumption and little or no additional computational burden.&lt;br /&gt;
&lt;br /&gt;
=== Requests for this Feature ===&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;cite&amp;gt;[https://lists.w3.org/Archives/Public/public-whatwg-archive/2013Jun/0114.html June 2013 whatwg thread]&amp;lt;/cite&amp;gt;&lt;br /&gt;
* &amp;lt;cite&amp;gt;[https://lists.w3.org/Archives/Public/public-whatwg-archive/2013Jul/0075.html July 2013 whatwg thread]&amp;lt;/cite&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Web IDL ==&lt;br /&gt;
&lt;br /&gt;
 enum ImageOrientation { &amp;quot;none&amp;quot;, &amp;quot;flipY&amp;quot; };&lt;br /&gt;
 enum PremultiplyAlpha { &amp;quot;none&amp;quot;, &amp;quot;premultiply&amp;quot;, &amp;quot;default&amp;quot; };&lt;br /&gt;
 enum ColorspaceConversion { &amp;quot;none&amp;quot;, &amp;quot;default&amp;quot; };&lt;br /&gt;
 dictionary ImageBitmapOptions {&lt;br /&gt;
   ImageOrientation imageOrientation = &amp;quot;none&amp;quot;;&lt;br /&gt;
   PremultiplyAlpha premultiplyAlpha = &amp;quot;default&amp;quot;;&lt;br /&gt;
   ColorspaceConversion colorspaceConversion = &amp;quot;default&amp;quot;;&lt;br /&gt;
 };&lt;br /&gt;
 &lt;br /&gt;
 partial interface ImageBitmapFactories {&lt;br /&gt;
   Promise&amp;lt;ImageBitmap&amp;gt; createImageBitmap(ImageBitmapSource image, ImageBitmapOptions options);&lt;br /&gt;
   Promise&amp;lt;ImageBitmap&amp;gt; createImageBitmap(ImageBitmapSource image, long sx, long sy, long sw, long sh, ImageBitmapOptions options);&lt;br /&gt;
 };&lt;br /&gt;
&lt;br /&gt;
* Note: This IDL reflects the &amp;quot;Strongly desired options&amp;quot; below.&lt;br /&gt;
&lt;br /&gt;
== Proposed Solutions ==&lt;br /&gt;
&lt;br /&gt;
=== ImageBitmap Construction Options ===&lt;br /&gt;
&lt;br /&gt;
:Add an optional &#039;&#039;options&#039;&#039; argument to createImageBitmap to specify image treatments to be applied when creating the ImageBitmap object.&lt;br /&gt;
&lt;br /&gt;
==== Strongly desired options ====&lt;br /&gt;
&lt;br /&gt;
* enum imageOrientation, default = &#039;none&#039; &amp;lt;blockquote&amp;gt;&amp;lt;p&amp;gt;&#039;none&#039;: Do not change orientation.&amp;lt;/p&amp;gt;&amp;lt;p&amp;gt;&#039;flipY&#039;: Flip image vertically, disregarding image orientation meta data (EXIF or other), if any.&amp;lt;/p&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
* enum colorspaceConversion, default = &#039;default&#039; &amp;lt;blockquote&amp;gt;&amp;lt;p&amp;gt;&#039;none&#039;: The ImageBitmap must be created by decoding the source image media without performing any colorspace conversions. This means that the image decoding algorithm must ignore color profile meta-data embedded in the image source as well as the display device color profile.  colorspaceConversion only applies when creating ImageBitmaps from bitmap media data (i.e. blobs and image elements with non-vector images)&amp;lt;/p&amp;gt; &amp;lt;p&amp;gt;&#039;default&#039;: Implementation-specific behavior, possibly optimized for the implementation&#039;s graphics framework.&amp;lt;/p&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
* enum premultiplyAlpha, default = &#039;default&#039; &amp;lt;blockquote&amp;gt;&amp;lt;p&amp;gt;&#039;none&#039;: Image sources that have raw image data that is not premultiplied by alpha will be left untouched and image sources that are premultiplied by alpha will have their color components divided by alpha.&amp;lt;/p&amp;gt;&amp;lt;p&amp;gt;&#039;premultiply&#039;: Image sources that have raw image data that is not premultiplied by alpha will have their color components multiplied by alpha and image sources that are premultiplied by alpha will be left untouched.&amp;lt;/p&amp;gt;&amp;lt;p&amp;gt;&#039;default&#039;: Implementation-specific behavior, possibly optimized for the implementation&#039;s graphics framework.&amp;lt;/p&amp;gt;&amp;lt;p&amp;gt;When premultiplyAlpha is set to &#039;none&#039;, the division by alpha may result in loss of precision, which must be avoided whenever possible. For example, if the image source is a blob or an image element, the decoded image may already be available in premultipled form. Rather than divide the already decoded data, the user agent must re-decode the image without premultiplying, thus ensuring that the ImageBitmap is delivered with the highest quality data.&amp;lt;/p&amp;gt;&amp;lt;p&amp;gt;Image sources that do not have an alpha channel are not affected by this option.&amp;lt;/p&amp;gt;&amp;lt;p&amp;gt;Caution: 2D Canvases may or may not be stored in premultipled form, depending on the implementation.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Other potentially useful options ====&lt;br /&gt;
* enum imageOrientation, &#039;topLeft&#039; and &#039;bottomLeft&#039; &amp;lt;blockquote&amp;gt;&amp;lt;p&amp;gt;&#039;topLeft&#039;:  identify visual orientation from image media meta data and re-order data so top-down, left-to-right processing for display results in correct visual orientation. If the image source is an ImageBitmap, the image data will be flipped vertically if and only if the source was created with bottomLeft orientation. If the image source holds no orientation information, the image orientation is not changed.&amp;lt;/p&amp;gt;&amp;lt;p&amp;gt;&#039;bottomLeft&#039;: identify visual orientation from image media meta data and re-order data so bottom-up, left-to-right processing for display results in correct visual orientation. If the image source is an ImageBitmap, the image data will be flipped vertically if and only if the source was created with topLeft orientation. If the image source holds no orientation information, the image is flipped vertically.&amp;lt;/p&amp;gt;&amp;lt;blockquote&amp;gt; &lt;br /&gt;
* DOMString? crossOrigin: The crossOrigin option is a [[https://html.spec.whatwg.org/multipage/infrastructure.html#cors-settings-attribute CORS settings attribute]]. It is consulted when [[ImageBitmap Constructor taking URL|constructing an ImageBitmap from the URL of an image]]. Because ImageBitmaps can only be constructed from same-origin resources, in order to construct an ImageBitmap from the URL of a cross-origin image resource, the crossOrigin option must be specified, and the server must grant the request. Otherwise the Promise returned from createImageBitmap will be rejected. &amp;lt;blockquote&amp;gt;&amp;lt;p&amp;gt;Note: this is a convenience feature. At this moment, using the process of XHR-&amp;gt;Blob-&amp;gt;ImageBitmap will achieve the same goal.&amp;lt;/p&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
* resizedWidth, resizedHeight: dimension to which the image should be resized. Could also be expressed using scale factors&lt;br /&gt;
* resizeFilter: filtering method used for scaling the image (pixelated, low quality, high quality, etc.)&lt;br /&gt;
* frameIndex: for creating an image bitmap from multi-frame image media&lt;br /&gt;
* flipX: like flipY but horizontal&lt;br /&gt;
* colorspace: to decode images to a colorspace other than the device colorspace (sRGB, Adobe RGB, YUV, YCbCr, etc.)&lt;br /&gt;
* custom color tranforms: color matrix, 3D Look up tables, per component look up tables, bias, gain, ... &lt;br /&gt;
&lt;br /&gt;
==== Processing Model ====&lt;br /&gt;
: These options affect the internal color representation used to store the ImageBitmap&#039;s bitmap data. The only observable effects would be on color fidelity. There would be no re-interpretation of color values. This is important because treating unpremultiplied colors as premultiplied is evil. For example, in blink&#039;s implementation, setting both options to &#039;none&#039; would have no side-effects on the graphical results of CanvasRenderingContext2D.drawImage(). The only difference would be that the color-space conversion and the multiplication by alpha would be deferred to drawImage(), instead of being applied during ImageBitmap creation. The usefulness of &#039;none&#039; is strictly for preventing losses in precision and gamut that may result from dividing by alpha and/or reversing the default color-space conversion when using APIs that would require it (WebGL&#039;s UNPACK_PREMULTIPLY_ALPHA_WEBGL and UNPACK_COLORSPACE_CONVERSION_WEBGL pixel storage parameters)&lt;br /&gt;
&lt;br /&gt;
==== Limitations ==== &lt;br /&gt;
: TBD &#039;&#039;Cases not covered by this solution in relation to the problem description; other problems with this solution, if any.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
==== Implementation ==== &lt;br /&gt;
: TBD &#039;&#039;Description of how and why browser vendors would take advantage of this feature.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
==== Adoption ==== &lt;br /&gt;
* Easier to develop asychronous image resource loading and preparation&lt;br /&gt;
* Better performance that what can be implemented using current APIs&lt;br /&gt;
* Applications can rely on the browser resource management facilities for caching decoded image data with the desired options baked-in and for evicting pre-decoded resources in low memory conditions to avoid out-of-memory crashes.&lt;br /&gt;
&lt;br /&gt;
==== See Also ====&lt;br /&gt;
&lt;br /&gt;
Related is the [[ImageBitmap Constructor taking URL]].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Proposals]]&lt;/div&gt;</summary>
		<author><name>Xidachen</name></author>
	</entry>
	<entry>
		<id>https://wiki.whatwg.org/index.php?title=ImageBitmap_Options&amp;diff=10034</id>
		<title>ImageBitmap Options</title>
		<link rel="alternate" type="text/html" href="https://wiki.whatwg.org/index.php?title=ImageBitmap_Options&amp;diff=10034"/>
		<updated>2016-02-10T19:52:42Z</updated>

		<summary type="html">&lt;p&gt;Xidachen: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
This page is a Work in Progress&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Problem to be solved&#039;&#039;&#039;: Loading and preparing image resources for rendering to 2D canvas contexts and WebGL contexts is often inefficient using existing APIs.&lt;br /&gt;
&lt;br /&gt;
== Use Case Description ==&lt;br /&gt;
:WebGL applications often use image media for transferring non-image data (illumination maps, vector maps, etc.) For such applications the image data must usually be decoded without colorspace conversions and without alpha premultiplications.&lt;br /&gt;
&lt;br /&gt;
=== Current Usage and Workarounds ===&lt;br /&gt;
&lt;br /&gt;
:Currently, there are several ways to apply arbitrary transformations on the client side, many of which involve intermediate copies of the image data. Some solutions involve DataURLs, temporary canvases, or direct manipulation of image data arrays, which are inefficient. Preparing the resources asynchronously also presents an additional challenge to the web developer.&lt;br /&gt;
&lt;br /&gt;
:WebGL applications can request that colorspace conversions be skipped at texture upload time by specifying pixel storage parameters, but this currently causes a synchronous image decode, because it is not known in advance that the image will need to be decoded in a special way. This latency is a significant problem for applications that upload many images to the GPU, such as Google Maps.&lt;br /&gt;
&lt;br /&gt;
:ImageBitmap offers an opportunity to provide exactly the desired image decoding options when the image is fetched, so that when the ImageBitmap is ready, it is in exactly the desired form for upload to the GPU.&lt;br /&gt;
&lt;br /&gt;
=== Benefits ===&lt;br /&gt;
&lt;br /&gt;
:With the right API support, image resources can be prepared asynchronously and/or in advance to avoid rendering latency issues. Furthermore, the preparation steps could be performed by native code, and in many case they can be integrated directly into the image decoding step without any additional memory consumption and little or no additional computational burden.&lt;br /&gt;
&lt;br /&gt;
=== Requests for this Feature ===&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;cite&amp;gt;[https://lists.w3.org/Archives/Public/public-whatwg-archive/2013Jun/0114.html June 2013 whatwg thread]&amp;lt;/cite&amp;gt;&lt;br /&gt;
* &amp;lt;cite&amp;gt;[https://lists.w3.org/Archives/Public/public-whatwg-archive/2013Jul/0075.html July 2013 whatwg thread]&amp;lt;/cite&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Proposed Solutions ==&lt;br /&gt;
&lt;br /&gt;
=== ImageBitmap Construction Options ===&lt;br /&gt;
&lt;br /&gt;
:Add an optional &#039;&#039;options&#039;&#039; argument to createImageBitmap to specify image treatments to be applied when creating the ImageBitmap object.&lt;br /&gt;
&lt;br /&gt;
==== Strongly desired options ====&lt;br /&gt;
&lt;br /&gt;
* enum imageOrientation, default = &#039;none&#039; &amp;lt;blockquote&amp;gt;&amp;lt;p&amp;gt;&#039;none&#039;: Do not change orientation.&amp;lt;/p&amp;gt;&amp;lt;p&amp;gt;&#039;flipY&#039;: Flip image vertically, disregarding image orientation meta data (EXIF or other), if any.&amp;lt;/p&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
* enum colorspaceConversion, default = &#039;default&#039; &amp;lt;blockquote&amp;gt;&amp;lt;p&amp;gt;&#039;none&#039;: The ImageBitmap must be created by decoding the source image media without performing any colorspace conversions. This means that the image decoding algorithm must ignore color profile meta-data embedded in the image source as well as the display device color profile.  colorspaceConversion only applies when creating ImageBitmaps from bitmap media data (i.e. blobs and image elements with non-vector images)&amp;lt;/p&amp;gt; &amp;lt;p&amp;gt;&#039;default&#039;: Implementation-specific behavior, possibly optimized for the implementation&#039;s graphics framework.&amp;lt;/p&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
* enum premultiplyAlpha, default = &#039;default&#039; &amp;lt;blockquote&amp;gt;&amp;lt;p&amp;gt;&#039;none&#039;: Image sources that have raw image data that is not premultiplied by alpha will be left untouched and image sources that are premultiplied by alpha will have their color components divided by alpha.&amp;lt;/p&amp;gt;&amp;lt;p&amp;gt;&#039;premultiply&#039;: Image sources that have raw image data that is not premultiplied by alpha will have their color components multiplied by alpha and image sources that are premultiplied by alpha will be left untouched.&amp;lt;/p&amp;gt;&amp;lt;p&amp;gt;&#039;default&#039;: Implementation-specific behavior, possibly optimized for the implementation&#039;s graphics framework.&amp;lt;/p&amp;gt;&amp;lt;p&amp;gt;When premultiplyAlpha is set to &#039;none&#039;, the division by alpha may result in loss of precision, which must be avoided whenever possible. For example, if the image source is a blob or an image element, the decoded image may already be available in premultipled form. Rather than divide the already decoded data, the user agent must re-decode the image without premultiplying, thus ensuring that the ImageBitmap is delivered with the highest quality data.&amp;lt;/p&amp;gt;&amp;lt;p&amp;gt;Image sources that do not have an alpha channel are not affected by this option.&amp;lt;/p&amp;gt;&amp;lt;p&amp;gt;Caution: 2D Canvases may or may not be stored in premultipled form, depending on the implementation.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Other potentially useful options ====&lt;br /&gt;
* enum imageOrientation, &#039;topLeft&#039; and &#039;bottomLeft&#039; &amp;lt;blockquote&amp;gt;&amp;lt;p&amp;gt;&#039;topLeft&#039;:  identify visual orientation from image media meta data and re-order data so top-down, left-to-right processing for display results in correct visual orientation. If the image source is an ImageBitmap, the image data will be flipped vertically if and only if the source was created with bottomLeft orientation. If the image source holds no orientation information, the image orientation is not changed.&amp;lt;/p&amp;gt;&amp;lt;p&amp;gt;&#039;bottomLeft&#039;: identify visual orientation from image media meta data and re-order data so bottom-up, left-to-right processing for display results in correct visual orientation. If the image source is an ImageBitmap, the image data will be flipped vertically if and only if the source was created with topLeft orientation. If the image source holds no orientation information, the image is flipped vertically.&amp;lt;/p&amp;gt;&amp;lt;blockquote&amp;gt; &lt;br /&gt;
* DOMString? crossOrigin: The crossOrigin option is a [[https://html.spec.whatwg.org/multipage/infrastructure.html#cors-settings-attribute CORS settings attribute]]. It is consulted when [[ImageBitmap Constructor taking URL|constructing an ImageBitmap from the URL of an image]]. Because ImageBitmaps can only be constructed from same-origin resources, in order to construct an ImageBitmap from the URL of a cross-origin image resource, the crossOrigin option must be specified, and the server must grant the request. Otherwise the Promise returned from createImageBitmap will be rejected. &amp;lt;blockquote&amp;gt;&amp;lt;p&amp;gt;Note: this is a convenience feature. At this moment, using the process of XHR-&amp;gt;Blob-&amp;gt;ImageBitmap will achieve the same goal.&amp;lt;/p&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
* resizedWidth, resizedHeight: dimension to which the image should be resized. Could also be expressed using scale factors&lt;br /&gt;
* resizeFilter: filtering method used for scaling the image (pixelated, low quality, high quality, etc.)&lt;br /&gt;
* frameIndex: for creating an image bitmap from multi-frame image media&lt;br /&gt;
* flipX: like flipY but horizontal&lt;br /&gt;
* colorspace: to decode images to a colorspace other than the device colorspace (sRGB, Adobe RGB, YUV, YCbCr, etc.)&lt;br /&gt;
* custom color tranforms: color matrix, 3D Look up tables, per component look up tables, bias, gain, ... &lt;br /&gt;
&lt;br /&gt;
==== Processing Model ====&lt;br /&gt;
: These options affect the internal color representation used to store the ImageBitmap&#039;s bitmap data. The only observable effects would be on color fidelity. There would be no re-interpretation of color values. This is important because treating unpremultiplied colors as premultiplied is evil. For example, in blink&#039;s implementation, setting both options to &#039;none&#039; would have no side-effects on the graphical results of CanvasRenderingContext2D.drawImage(). The only difference would be that the color-space conversion and the multiplication by alpha would be deferred to drawImage(), instead of being applied during ImageBitmap creation. The usefulness of &#039;none&#039; is strictly for preventing losses in precision and gamut that may result from dividing by alpha and/or reversing the default color-space conversion when using APIs that would require it (WebGL&#039;s UNPACK_PREMULTIPLY_ALPHA_WEBGL and UNPACK_COLORSPACE_CONVERSION_WEBGL pixel storage parameters)&lt;br /&gt;
&lt;br /&gt;
==== Limitations ==== &lt;br /&gt;
: TBD &#039;&#039;Cases not covered by this solution in relation to the problem description; other problems with this solution, if any.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
==== Implementation ==== &lt;br /&gt;
: TBD &#039;&#039;Description of how and why browser vendors would take advantage of this feature.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
==== Adoption ==== &lt;br /&gt;
* Easier to develop asychronous image resource loading and preparation&lt;br /&gt;
* Better performance that what can be implemented using current APIs&lt;br /&gt;
* Applications can rely on the browser resource management facilities for caching decoded image data with the desired options baked-in and for evicting pre-decoded resources in low memory conditions to avoid out-of-memory crashes.&lt;br /&gt;
&lt;br /&gt;
==== See Also ====&lt;br /&gt;
&lt;br /&gt;
Related is the [[ImageBitmap Constructor taking URL]].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Proposals]]&lt;/div&gt;</summary>
		<author><name>Xidachen</name></author>
	</entry>
	<entry>
		<id>https://wiki.whatwg.org/index.php?title=ImageBitmap_Options&amp;diff=10033</id>
		<title>ImageBitmap Options</title>
		<link rel="alternate" type="text/html" href="https://wiki.whatwg.org/index.php?title=ImageBitmap_Options&amp;diff=10033"/>
		<updated>2016-02-10T19:49:41Z</updated>

		<summary type="html">&lt;p&gt;Xidachen: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
This page is a Work in Progress&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Problem to be solved&#039;&#039;&#039;: Loading and preparing image resources for rendering to 2D canvas contexts and WebGL contexts is often inefficient using existing APIs.&lt;br /&gt;
&lt;br /&gt;
== Use Case Description ==&lt;br /&gt;
:WebGL applications often use image media for transferring non-image data (illumination maps, vector maps, etc.) For such applications the image data must usually be decoded without colorspace conversions and without alpha premultiplications.&lt;br /&gt;
&lt;br /&gt;
=== Current Usage and Workarounds ===&lt;br /&gt;
&lt;br /&gt;
:Currently, there are several ways to apply arbitrary transformations on the client side, many of which involve intermediate copies of the image data. Some solutions involve DataURLs, temporary canvases, or direct manipulation of image data arrays, which are inefficient. Preparing the resources asynchronously also presents an additional challenge to the web developer.&lt;br /&gt;
&lt;br /&gt;
:WebGL applications can request that colorspace conversions be skipped at texture upload time by specifying pixel storage parameters, but this currently causes a synchronous image decode, because it is not known in advance that the image will need to be decoded in a special way. This latency is a significant problem for applications that upload many images to the GPU, such as Google Maps.&lt;br /&gt;
&lt;br /&gt;
:ImageBitmap offers an opportunity to provide exactly the desired image decoding options when the image is fetched, so that when the ImageBitmap is ready, it is in exactly the desired form for upload to the GPU.&lt;br /&gt;
&lt;br /&gt;
=== Benefits ===&lt;br /&gt;
&lt;br /&gt;
:With the right API support, image resources can be prepared asynchronously and/or in advance to avoid rendering latency issues. Furthermore, the preparation steps could be performed by native code, and in many case they can be integrated directly into the image decoding step without any additional memory consumption and little or no additional computational burden.&lt;br /&gt;
&lt;br /&gt;
=== Requests for this Feature ===&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;cite&amp;gt;[https://lists.w3.org/Archives/Public/public-whatwg-archive/2013Jun/0114.html June 2013 whatwg thread]&amp;lt;/cite&amp;gt;&lt;br /&gt;
* &amp;lt;cite&amp;gt;[https://lists.w3.org/Archives/Public/public-whatwg-archive/2013Jul/0075.html July 2013 whatwg thread]&amp;lt;/cite&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Proposed Solutions ==&lt;br /&gt;
&lt;br /&gt;
=== ImageBitmap Construction Options ===&lt;br /&gt;
&lt;br /&gt;
:Add an optional &#039;&#039;options&#039;&#039; argument to createImageBitmap to specify image treatments to be applied when creating the ImageBitmap object.&lt;br /&gt;
&lt;br /&gt;
==== Strongly desired options ====&lt;br /&gt;
&lt;br /&gt;
* enum imageOrientation, default = &#039;none&#039; &amp;lt;blockquote&amp;gt;&amp;lt;p&amp;gt;&#039;none&#039;: Do not change orientation.&amp;lt;/p&amp;gt;&amp;lt;p&amp;gt;&#039;flipY&#039;: Flip image vertically, disregarding image orientation meta data (EXIF or other), if any.&amp;lt;/p&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
* enum colorspaceConversion, default = &#039;default&#039; &amp;lt;blockquote&amp;gt;&amp;lt;p&amp;gt;&#039;none&#039;: The ImageBitmap must be created by decoding the source image media without performing any colorspace conversions. This means that the image decoding algorithm must ignore color profile meta-data embedded in the image source as well as the display device color profile.  colorspaceConversion only applies when creating ImageBitmaps from bitmap media data (i.e. blobs and image elements with non-vector images)&amp;lt;/p&amp;gt; &amp;lt;p&amp;gt;&#039;default&#039;: Implementation-specific behavior, possibly optimized for the implementation&#039;s graphics framework.&amp;lt;/p&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
* enum premultiplyAlpha, default = &#039;default&#039; &amp;lt;blockquote&amp;gt;&amp;lt;p&amp;gt;&#039;none&#039;: Image sources that have raw image data that is not premultiplied by alpha will be left untouched and image sources that are premultiplied by alpha will have their color components divided by alpha.&amp;lt;/p&amp;gt;&amp;lt;p&amp;gt;&#039;true&#039;: Image sources that have raw image data that is not premultiplied by alpha will have their color components multiplied by alpha and image sources that are premultiplied by alpha will be left untouched.&amp;lt;/p&amp;gt;&amp;lt;p&amp;gt;&#039;default&#039;: Implementation-specific behavior, possibly optimized for the implementation&#039;s graphics framework.&amp;lt;/p&amp;gt;&amp;lt;p&amp;gt;When premultiplyAlpha is set to &#039;none&#039;, the division by alpha may result in loss of precision, which must be avoided whenever possible. For example, if the image source is a blob or an image element, the decoded image may already be available in premultipled form. Rather than divide the already decoded data, the user agent must re-decode the image without premultiplying, thus ensuring that the ImageBitmap is delivered with the highest quality data.&amp;lt;/p&amp;gt;&amp;lt;p&amp;gt;Image sources that do not have an alpha channel are not affected by this option.&amp;lt;/p&amp;gt;&amp;lt;p&amp;gt;Caution: 2D Canvases may or may not be stored in premultipled form, depending on the implementation.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Other potentially useful options ====&lt;br /&gt;
* enum imageOrientation, &#039;topLeft&#039; and &#039;bottomLeft&#039; &amp;lt;blockquote&amp;gt;&amp;lt;p&amp;gt;&#039;topLeft&#039;:  identify visual orientation from image media meta data and re-order data so top-down, left-to-right processing for display results in correct visual orientation. If the image source is an ImageBitmap, the image data will be flipped vertically if and only if the source was created with bottomLeft orientation. If the image source holds no orientation information, the image orientation is not changed.&amp;lt;/p&amp;gt;&amp;lt;p&amp;gt;&#039;bottomLeft&#039;: identify visual orientation from image media meta data and re-order data so bottom-up, left-to-right processing for display results in correct visual orientation. If the image source is an ImageBitmap, the image data will be flipped vertically if and only if the source was created with topLeft orientation. If the image source holds no orientation information, the image is flipped vertically.&amp;lt;/p&amp;gt;&amp;lt;blockquote&amp;gt; &lt;br /&gt;
* DOMString? crossOrigin: The crossOrigin option is a [[https://html.spec.whatwg.org/multipage/infrastructure.html#cors-settings-attribute CORS settings attribute]]. It is consulted when [[ImageBitmap Constructor taking URL|constructing an ImageBitmap from the URL of an image]]. Because ImageBitmaps can only be constructed from same-origin resources, in order to construct an ImageBitmap from the URL of a cross-origin image resource, the crossOrigin option must be specified, and the server must grant the request. Otherwise the Promise returned from createImageBitmap will be rejected. &amp;lt;blockquote&amp;gt;&amp;lt;p&amp;gt;Note: this is a convenience feature. At this moment, using the process of XHR-&amp;gt;Blob-&amp;gt;ImageBitmap will achieve the same goal.&amp;lt;/p&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
* resizedWidth, resizedHeight: dimension to which the image should be resized. Could also be expressed using scale factors&lt;br /&gt;
* resizeFilter: filtering method used for scaling the image (pixelated, low quality, high quality, etc.)&lt;br /&gt;
* frameIndex: for creating an image bitmap from multi-frame image media&lt;br /&gt;
* flipX: like flipY but horizontal&lt;br /&gt;
* colorspace: to decode images to a colorspace other than the device colorspace (sRGB, Adobe RGB, YUV, YCbCr, etc.)&lt;br /&gt;
* custom color tranforms: color matrix, 3D Look up tables, per component look up tables, bias, gain, ... &lt;br /&gt;
&lt;br /&gt;
==== Processing Model ====&lt;br /&gt;
: These options affect the internal color representation used to store the ImageBitmap&#039;s bitmap data. The only observable effects would be on color fidelity. There would be no re-interpretation of color values. This is important because treating unpremultiplied colors as premultiplied is evil. For example, in blink&#039;s implementation, setting both options to &#039;none&#039; would have no side-effects on the graphical results of CanvasRenderingContext2D.drawImage(). The only difference would be that the color-space conversion and the multiplication by alpha would be deferred to drawImage(), instead of being applied during ImageBitmap creation. The usefulness of &#039;none&#039; is strictly for preventing losses in precision and gamut that may result from dividing by alpha and/or reversing the default color-space conversion when using APIs that would require it (WebGL&#039;s UNPACK_PREMULTIPLY_ALPHA_WEBGL and UNPACK_COLORSPACE_CONVERSION_WEBGL pixel storage parameters)&lt;br /&gt;
&lt;br /&gt;
==== Limitations ==== &lt;br /&gt;
: TBD &#039;&#039;Cases not covered by this solution in relation to the problem description; other problems with this solution, if any.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
==== Implementation ==== &lt;br /&gt;
: TBD &#039;&#039;Description of how and why browser vendors would take advantage of this feature.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
==== Adoption ==== &lt;br /&gt;
* Easier to develop asychronous image resource loading and preparation&lt;br /&gt;
* Better performance that what can be implemented using current APIs&lt;br /&gt;
* Applications can rely on the browser resource management facilities for caching decoded image data with the desired options baked-in and for evicting pre-decoded resources in low memory conditions to avoid out-of-memory crashes.&lt;br /&gt;
&lt;br /&gt;
==== See Also ====&lt;br /&gt;
&lt;br /&gt;
Related is the [[ImageBitmap Constructor taking URL]].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Proposals]]&lt;/div&gt;</summary>
		<author><name>Xidachen</name></author>
	</entry>
	<entry>
		<id>https://wiki.whatwg.org/index.php?title=ImageBitmap_Options&amp;diff=10032</id>
		<title>ImageBitmap Options</title>
		<link rel="alternate" type="text/html" href="https://wiki.whatwg.org/index.php?title=ImageBitmap_Options&amp;diff=10032"/>
		<updated>2016-02-09T15:46:48Z</updated>

		<summary type="html">&lt;p&gt;Xidachen: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
This page is a Work in Progress&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Problem to be solved&#039;&#039;&#039;: Loading and preparing image resources for rendering to 2D canvas contexts and WebGL contexts is often inefficient using existing APIs.&lt;br /&gt;
&lt;br /&gt;
== Use Case Description ==&lt;br /&gt;
:WebGL applications often use image media for transferring non-image data (illumination maps, vector maps, etc.) For such applications the image data must usually be decoded without colorspace conversions and without alpha premultiplications.&lt;br /&gt;
&lt;br /&gt;
=== Current Usage and Workarounds ===&lt;br /&gt;
&lt;br /&gt;
:Currently, there are several ways to apply arbitrary transformations on the client side, many of which involve intermediate copies of the image data. Some solutions involve DataURLs, temporary canvases, or direct manipulation of image data arrays, which are inefficient. Preparing the resources asynchronously also presents an additional challenge to the web developer.&lt;br /&gt;
&lt;br /&gt;
:WebGL applications can request that colorspace conversions be skipped at texture upload time by specifying pixel storage parameters, but this currently causes a synchronous image decode, because it is not known in advance that the image will need to be decoded in a special way. This latency is a significant problem for applications that upload many images to the GPU, such as Google Maps.&lt;br /&gt;
&lt;br /&gt;
:ImageBitmap offers an opportunity to provide exactly the desired image decoding options when the image is fetched, so that when the ImageBitmap is ready, it is in exactly the desired form for upload to the GPU.&lt;br /&gt;
&lt;br /&gt;
=== Benefits ===&lt;br /&gt;
&lt;br /&gt;
:With the right API support, image resources can be prepared asynchronously and/or in advance to avoid rendering latency issues. Furthermore, the preparation steps could be performed by native code, and in many case they can be integrated directly into the image decoding step without any additional memory consumption and little or no additional computational burden.&lt;br /&gt;
&lt;br /&gt;
=== Requests for this Feature ===&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;cite&amp;gt;[https://lists.w3.org/Archives/Public/public-whatwg-archive/2013Jun/0114.html June 2013 whatwg thread]&amp;lt;/cite&amp;gt;&lt;br /&gt;
* &amp;lt;cite&amp;gt;[https://lists.w3.org/Archives/Public/public-whatwg-archive/2013Jul/0075.html July 2013 whatwg thread]&amp;lt;/cite&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Proposed Solutions ==&lt;br /&gt;
&lt;br /&gt;
=== ImageBitmap Construction Options ===&lt;br /&gt;
&lt;br /&gt;
:Add an optional &#039;&#039;options&#039;&#039; argument to createImageBitmap to specify image treatments to be applied when creating the ImageBitmap object.&lt;br /&gt;
&lt;br /&gt;
==== Strongly desired options ====&lt;br /&gt;
&lt;br /&gt;
* enum imageOrientation, default = &#039;none&#039; &amp;lt;blockquote&amp;gt;&amp;lt;p&amp;gt;&#039;none&#039;: Do not change orientation.&amp;lt;/p&amp;gt;&amp;lt;p&amp;gt;&#039;flipY&#039;: Flip image vertically, disregarding image orientation meta data (EXIF or other), if any.&amp;lt;/p&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
* enum colorspaceConversion, default = &#039;default&#039; &amp;lt;blockquote&amp;gt;&amp;lt;p&amp;gt;&#039;none&#039;: The ImageBitmap must be created by decoding the source image media without performing any colorspace conversions. This means that the image decoding algorithm must ignore color profile meta-data embedded in the image source as well as the display device color profile.  colorspaceConversion only applies when creating ImageBitmaps from bitmap media data (i.e. blobs and image elements with non-vector images)&amp;lt;/p&amp;gt; &amp;lt;p&amp;gt;&#039;default&#039;: Implementation-specific behavior, possibly optimized for the implementation&#039;s graphics framework.&amp;lt;/p&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
* enum premultiplyAlpha, default = &#039;default&#039; &amp;lt;blockquote&amp;gt;&amp;lt;p&amp;gt;&#039;none&#039;: Image sources that have raw image data that is not premultiplied by alpha will be left untouched and image sources that are premultiplied by alpha will have their color components divided by alpha.&amp;lt;/p&amp;gt;&amp;lt;p&amp;gt;&#039;default&#039;: Implementation-specific behavior, possibly optimized for the implementation&#039;s graphics framework.&amp;lt;/p&amp;gt;&amp;lt;p&amp;gt;When premultiplyAlpha is set to &#039;none&#039;, the division by alpha may result in loss of precision, which must be avoided whenever possible. For example, if the image source is a blob or an image element, the decoded image may already be available in premultipled form. Rather than divide the already decoded data, the user agent must re-decode the image without premultiplying, thus ensuring that the ImageBitmap is delivered with the highest quality data.&amp;lt;/p&amp;gt;&amp;lt;p&amp;gt;Image sources that do not have an alpha channel are not affected by this option.&amp;lt;/p&amp;gt;&amp;lt;p&amp;gt;Caution: 2D Canvases may or may not be stored in premultipled form, depending on the implementation.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Other potentially useful options ====&lt;br /&gt;
* enum imageOrientation, &#039;topLeft&#039; and &#039;bottomLeft&#039; &amp;lt;blockquote&amp;gt;&amp;lt;p&amp;gt;&#039;topLeft&#039;:  identify visual orientation from image media meta data and re-order data so top-down, left-to-right processing for display results in correct visual orientation. If the image source is an ImageBitmap, the image data will be flipped vertically if and only if the source was created with bottomLeft orientation. If the image source holds no orientation information, the image orientation is not changed.&amp;lt;/p&amp;gt;&amp;lt;p&amp;gt;&#039;bottomLeft&#039;: identify visual orientation from image media meta data and re-order data so bottom-up, left-to-right processing for display results in correct visual orientation. If the image source is an ImageBitmap, the image data will be flipped vertically if and only if the source was created with topLeft orientation. If the image source holds no orientation information, the image is flipped vertically.&amp;lt;/p&amp;gt;&amp;lt;blockquote&amp;gt; &lt;br /&gt;
* DOMString? crossOrigin: The crossOrigin option is a [[https://html.spec.whatwg.org/multipage/infrastructure.html#cors-settings-attribute CORS settings attribute]]. It is consulted when [[ImageBitmap Constructor taking URL|constructing an ImageBitmap from the URL of an image]]. Because ImageBitmaps can only be constructed from same-origin resources, in order to construct an ImageBitmap from the URL of a cross-origin image resource, the crossOrigin option must be specified, and the server must grant the request. Otherwise the Promise returned from createImageBitmap will be rejected. &amp;lt;blockquote&amp;gt;&amp;lt;p&amp;gt;Note: this is a convenience feature. At this moment, using the process of XHR-&amp;gt;Blob-&amp;gt;ImageBitmap will achieve the same goal.&amp;lt;/p&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
* resizedWidth, resizedHeight: dimension to which the image should be resized. Could also be expressed using scale factors&lt;br /&gt;
* resizeFilter: filtering method used for scaling the image (pixelated, low quality, high quality, etc.)&lt;br /&gt;
* frameIndex: for creating an image bitmap from multi-frame image media&lt;br /&gt;
* flipX: like flipY but horizontal&lt;br /&gt;
* colorspace: to decode images to a colorspace other than the device colorspace (sRGB, Adobe RGB, YUV, YCbCr, etc.)&lt;br /&gt;
* custom color tranforms: color matrix, 3D Look up tables, per component look up tables, bias, gain, ... &lt;br /&gt;
&lt;br /&gt;
==== Processing Model ====&lt;br /&gt;
: These options affect the internal color representation used to store the ImageBitmap&#039;s bitmap data. The only observable effects would be on color fidelity. There would be no re-interpretation of color values. This is important because treating unpremultiplied colors as premultiplied is evil. For example, in blink&#039;s implementation, setting both options to &#039;none&#039; would have no side-effects on the graphical results of CanvasRenderingContext2D.drawImage(). The only difference would be that the color-space conversion and the multiplication by alpha would be deferred to drawImage(), instead of being applied during ImageBitmap creation. The usefulness of &#039;none&#039; is strictly for preventing losses in precision and gamut that may result from dividing by alpha and/or reversing the default color-space conversion when using APIs that would require it (WebGL&#039;s UNPACK_PREMULTIPLY_ALPHA_WEBGL and UNPACK_COLORSPACE_CONVERSION_WEBGL pixel storage parameters)&lt;br /&gt;
&lt;br /&gt;
==== Limitations ==== &lt;br /&gt;
: TBD &#039;&#039;Cases not covered by this solution in relation to the problem description; other problems with this solution, if any.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
==== Implementation ==== &lt;br /&gt;
: TBD &#039;&#039;Description of how and why browser vendors would take advantage of this feature.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
==== Adoption ==== &lt;br /&gt;
* Easier to develop asychronous image resource loading and preparation&lt;br /&gt;
* Better performance that what can be implemented using current APIs&lt;br /&gt;
* Applications can rely on the browser resource management facilities for caching decoded image data with the desired options baked-in and for evicting pre-decoded resources in low memory conditions to avoid out-of-memory crashes.&lt;br /&gt;
&lt;br /&gt;
==== See Also ====&lt;br /&gt;
&lt;br /&gt;
Related is the [[ImageBitmap Constructor taking URL]].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Proposals]]&lt;/div&gt;</summary>
		<author><name>Xidachen</name></author>
	</entry>
	<entry>
		<id>https://wiki.whatwg.org/index.php?title=ImageBitmap_Options&amp;diff=10031</id>
		<title>ImageBitmap Options</title>
		<link rel="alternate" type="text/html" href="https://wiki.whatwg.org/index.php?title=ImageBitmap_Options&amp;diff=10031"/>
		<updated>2016-02-08T21:31:47Z</updated>

		<summary type="html">&lt;p&gt;Xidachen: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
This page is a Work in Progress&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Problem to be solved&#039;&#039;&#039;: Loading and preparing image resources for rendering to 2D canvas contexts and WebGL contexts is often inefficient using existing APIs.&lt;br /&gt;
&lt;br /&gt;
== Use Case Description ==&lt;br /&gt;
:WebGL applications often use image media for transferring non-image data (illumination maps, vector maps, etc.) For such applications the image data must usually be decoded without colorspace conversions and without alpha premultiplications.&lt;br /&gt;
&lt;br /&gt;
=== Current Usage and Workarounds ===&lt;br /&gt;
&lt;br /&gt;
:Currently, there are several ways to apply arbitrary transformations on the client side, many of which involve intermediate copies of the image data. Some solutions involve DataURLs, temporary canvases, or direct manipulation of image data arrays, which are inefficient. Preparing the resources asynchronously also presents an additional challenge to the web developer.&lt;br /&gt;
&lt;br /&gt;
:WebGL applications can request that colorspace conversions be skipped at texture upload time by specifying pixel storage parameters, but this currently causes a synchronous image decode, because it is not known in advance that the image will need to be decoded in a special way. This latency is a significant problem for applications that upload many images to the GPU, such as Google Maps.&lt;br /&gt;
&lt;br /&gt;
:ImageBitmap offers an opportunity to provide exactly the desired image decoding options when the image is fetched, so that when the ImageBitmap is ready, it is in exactly the desired form for upload to the GPU.&lt;br /&gt;
&lt;br /&gt;
=== Benefits ===&lt;br /&gt;
&lt;br /&gt;
:With the right API support, image resources can be prepared asynchronously and/or in advance to avoid rendering latency issues. Furthermore, the preparation steps could be performed by native code, and in many case they can be integrated directly into the image decoding step without any additional memory consumption and little or no additional computational burden.&lt;br /&gt;
&lt;br /&gt;
=== Requests for this Feature ===&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;cite&amp;gt;[https://lists.w3.org/Archives/Public/public-whatwg-archive/2013Jun/0114.html June 2013 whatwg thread]&amp;lt;/cite&amp;gt;&lt;br /&gt;
* &amp;lt;cite&amp;gt;[https://lists.w3.org/Archives/Public/public-whatwg-archive/2013Jul/0075.html July 2013 whatwg thread]&amp;lt;/cite&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Proposed Solutions ==&lt;br /&gt;
&lt;br /&gt;
=== ImageBitmap Construction Options ===&lt;br /&gt;
&lt;br /&gt;
:Add an optional &#039;&#039;options&#039;&#039; argument to createImageBitmap to specify image treatments to be applied when creating the ImageBitmap object.&lt;br /&gt;
&lt;br /&gt;
==== Strongly desired options ====&lt;br /&gt;
&lt;br /&gt;
* enum imageOrientation, default = &#039;none&#039; &amp;lt;blockquote&amp;gt;&amp;lt;p&amp;gt;&#039;none&#039;: Do not change orientation.&amp;lt;/p&amp;gt;&amp;lt;p&amp;gt;&#039;flipY&#039;: Flip image vertically, disregarding image orientation meta data (EXIF or other), if any.&amp;lt;/p&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
* enum colorspaceConversion, default = &#039;default&#039; &amp;lt;blockquote&amp;gt;&amp;lt;p&amp;gt;&#039;none&#039;: The ImageBitmap must be created by decoding the source image media without performing any colorspace conversions. This means that the image decoding algorithm must ignore color profile meta-data embedded in the image source as well as the display device color profile.  colorspaceConversion only applies when creating ImageBitmaps from bitmap media data (i.e. blobs and image elements with non-vector images)&amp;lt;/p&amp;gt; &amp;lt;p&amp;gt;&#039;default&#039;: Implementation-specific behavior, possibly optimized for the implementation&#039;s graphics framework.&amp;lt;/p&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
* enum premultiplyAlpha, default = &#039;default&#039; &amp;lt;blockquote&amp;gt;&amp;lt;p&amp;gt;&#039;none&#039;: Image sources that have raw image data that is not premultiplied by alpha will be left untouched and image sources that are premultiplied by alpha will have their color components divided by alpha.&amp;lt;/p&amp;gt;&amp;lt;p&amp;gt;&#039;default&#039;: Implementation-specific behavior, possibly optimized for the implementation&#039;s graphics framework.&amp;lt;/p&amp;gt;&amp;lt;p&amp;gt;When premultiplyAlpha is set to &#039;none&#039;, the division by alpha may result in loss of precision, which must be avoided whenever possible. For example, if the image source is a blob or an image element, the decoded image may already be available in premultipled form. Rather than divide the already decoded data, the user agent must re-decode the image without premultiplying, thus ensuring that the ImageBitmap is delivered with the highest quality data.&amp;lt;/p&amp;gt;&amp;lt;p&amp;gt;Image sources that do not have an alpha channel are not affected by this option.&amp;lt;/p&amp;gt;&amp;lt;p&amp;gt;Caution: 2D Canvases may or may not be stored in premultipled form, depending on the implementation.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Other potentially useful options ====&lt;br /&gt;
* enum imageOrientation, &#039;topLeft&#039; and &#039;bottomLeft&#039; &amp;lt;blockquote&amp;gt;&amp;lt;p&amp;gt;&#039;topLeft&#039;:  identify visual orientation from image media meta data and re-order data so top-down, left-to-right processing for display results in correct visual orientation. If the image source is an ImageBitmap, the image data will be flipped vertically if and only if the source was created with bottomLeft orientation. If the image source holds no orientation information, the image orientation is not changed.&amp;lt;/p&amp;gt;&amp;lt;p&amp;gt;&#039;bottomLeft&#039;: identify visual orientation from image media meta data and re-order data so bottom-up, left-to-right processing for display results in correct visual orientation. If the image source is an ImageBitmap, the image data will be flipped vertically if and only if the source was created with topLeft orientation. If the image source holds no orientation information, the image is flipped vertically.&amp;lt;/p&amp;gt;&amp;lt;blockquote&amp;gt; &lt;br /&gt;
* DOMString? crossOrigin: The crossOrigin option is a [[https://html.spec.whatwg.org/multipage/infrastructure.html#cors-settings-attribute CORS settings attribute]]. It is consulted when [[ImageBitmap Constructor taking URL|constructing an ImageBitmap from the URL of an image]]. Because ImageBitmaps can only be constructed from same-origin resources, in order to construct an ImageBitmap from the URL of a cross-origin image resource, the crossOrigin option must be specified, and the server must grant the request. Otherwise the Promise returned from createImageBitmap will be rejected.&lt;br /&gt;
* resizedWidth, resizedHeight: dimension to which the image should be resized. Could also be expressed using scale factors&lt;br /&gt;
* resizeFilter: filtering method used for scaling the image (pixelated, low quality, high quality, etc.)&lt;br /&gt;
* frameIndex: for creating an image bitmap from multi-frame image media&lt;br /&gt;
* flipX: like flipY but horizontal&lt;br /&gt;
* colorspace: to decode images to a colorspace other than the device colorspace (sRGB, Adobe RGB, YUV, YCbCr, etc.)&lt;br /&gt;
* custom color tranforms: color matrix, 3D Look up tables, per component look up tables, bias, gain, ... &lt;br /&gt;
&lt;br /&gt;
==== Processing Model ====&lt;br /&gt;
: These options affect the internal color representation used to store the ImageBitmap&#039;s bitmap data. The only observable effects would be on color fidelity. There would be no re-interpretation of color values. This is important because treating unpremultiplied colors as premultiplied is evil. For example, in blink&#039;s implementation, setting both options to &#039;none&#039; would have no side-effects on the graphical results of CanvasRenderingContext2D.drawImage(). The only difference would be that the color-space conversion and the multiplication by alpha would be deferred to drawImage(), instead of being applied during ImageBitmap creation. The usefulness of &#039;none&#039; is strictly for preventing losses in precision and gamut that may result from dividing by alpha and/or reversing the default color-space conversion when using APIs that would require it (WebGL&#039;s UNPACK_PREMULTIPLY_ALPHA_WEBGL and UNPACK_COLORSPACE_CONVERSION_WEBGL pixel storage parameters)&lt;br /&gt;
&lt;br /&gt;
==== Limitations ==== &lt;br /&gt;
: TBD &#039;&#039;Cases not covered by this solution in relation to the problem description; other problems with this solution, if any.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
==== Implementation ==== &lt;br /&gt;
: TBD &#039;&#039;Description of how and why browser vendors would take advantage of this feature.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
==== Adoption ==== &lt;br /&gt;
* Easier to develop asychronous image resource loading and preparation&lt;br /&gt;
* Better performance that what can be implemented using current APIs&lt;br /&gt;
* Applications can rely on the browser resource management facilities for caching decoded image data with the desired options baked-in and for evicting pre-decoded resources in low memory conditions to avoid out-of-memory crashes.&lt;br /&gt;
&lt;br /&gt;
==== See Also ====&lt;br /&gt;
&lt;br /&gt;
Related is the [[ImageBitmap Constructor taking URL]].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Proposals]]&lt;/div&gt;</summary>
		<author><name>Xidachen</name></author>
	</entry>
	<entry>
		<id>https://wiki.whatwg.org/index.php?title=ImageBitmap_Options&amp;diff=10030</id>
		<title>ImageBitmap Options</title>
		<link rel="alternate" type="text/html" href="https://wiki.whatwg.org/index.php?title=ImageBitmap_Options&amp;diff=10030"/>
		<updated>2016-02-08T20:47:44Z</updated>

		<summary type="html">&lt;p&gt;Xidachen: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
This page is a Work in Progress&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Problem to be solved&#039;&#039;&#039;: Loading and preparing image resources for rendering to 2D canvas contexts and WebGL contexts is often inefficient using existing APIs.&lt;br /&gt;
&lt;br /&gt;
== Use Case Description ==&lt;br /&gt;
:WebGL applications often use image media for transferring non-image data (illumination maps, vector maps, etc.) For such applications the image data must usually be decoded without colorspace conversions and without alpha premultiplications.&lt;br /&gt;
&lt;br /&gt;
=== Current Usage and Workarounds ===&lt;br /&gt;
&lt;br /&gt;
:Currently, there are several ways to apply arbitrary transformations on the client side, many of which involve intermediate copies of the image data. Some solutions involve DataURLs, temporary canvases, or direct manipulation of image data arrays, which are inefficient. Preparing the resources asynchronously also presents an additional challenge to the web developer.&lt;br /&gt;
&lt;br /&gt;
:WebGL applications can request that colorspace conversions be skipped at texture upload time by specifying pixel storage parameters, but this currently causes a synchronous image decode, because it is not known in advance that the image will need to be decoded in a special way. This latency is a significant problem for applications that upload many images to the GPU, such as Google Maps.&lt;br /&gt;
&lt;br /&gt;
:ImageBitmap offers an opportunity to provide exactly the desired image decoding options when the image is fetched, so that when the ImageBitmap is ready, it is in exactly the desired form for upload to the GPU.&lt;br /&gt;
&lt;br /&gt;
=== Benefits ===&lt;br /&gt;
&lt;br /&gt;
:With the right API support, image resources can be prepared asynchronously and/or in advance to avoid rendering latency issues. Furthermore, the preparation steps could be performed by native code, and in many case they can be integrated directly into the image decoding step without any additional memory consumption and little or no additional computational burden.&lt;br /&gt;
&lt;br /&gt;
=== Requests for this Feature ===&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;cite&amp;gt;[https://lists.w3.org/Archives/Public/public-whatwg-archive/2013Jun/0114.html June 2013 whatwg thread]&amp;lt;/cite&amp;gt;&lt;br /&gt;
* &amp;lt;cite&amp;gt;[https://lists.w3.org/Archives/Public/public-whatwg-archive/2013Jul/0075.html July 2013 whatwg thread]&amp;lt;/cite&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Proposed Solutions ==&lt;br /&gt;
&lt;br /&gt;
=== ImageBitmap Construction Options ===&lt;br /&gt;
&lt;br /&gt;
:Add an optional &#039;&#039;options&#039;&#039; argument to createImageBitmap to specify image treatments to be applied when creating the ImageBitmap object.&lt;br /&gt;
&lt;br /&gt;
==== Strongly desired options ====&lt;br /&gt;
&lt;br /&gt;
* enum imageOrientation, default = &#039;none&#039; &amp;lt;blockquote&amp;gt;&amp;lt;p&amp;gt;&#039;none&#039;: Do not change orientation.&amp;lt;/p&amp;gt;&amp;lt;p&amp;gt;&#039;flipY&#039;: Flip image vertically, disregarding image orientation meta data (EXIF or other), if any.&amp;lt;/p&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
* enum colorspaceConversion, default = &#039;default&#039; &amp;lt;blockquote&amp;gt;&amp;lt;p&amp;gt;&#039;none&#039;: The ImageBitmap must be created by decoding the source image media without performing any colorspace conversions. This means that the image decoding algorithm must ignore color profile meta-data embedded in the image source as well as the display device color profile.  colorspaceConversion only applies when creating ImageBitmaps from bitmap media data (i.e. blobs and image elements with non-vector images)&amp;lt;/p&amp;gt; &amp;lt;p&amp;gt;&#039;default&#039;: Implementation-specific behavior, possibly optimized for the implementation&#039;s graphics framework.&amp;lt;/p&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
* enum premultiplyAlpha, default = &#039;default&#039; &amp;lt;blockquote&amp;gt;&amp;lt;p&amp;gt;&#039;none&#039;: Image sources that have raw image data that is not premultiplied by alpha will be left untouched and image sources that are premultiplied by alpha will have their color components divided by alpha.&amp;lt;/p&amp;gt;&amp;lt;p&amp;gt;&#039;default&#039;: Implementation-specific behavior, possibly optimized for the implementation&#039;s graphics framework.&amp;lt;/p&amp;gt;&amp;lt;p&amp;gt;When premultiplyAlpha is set to &#039;none&#039;, the division by alpha may result in loss of precision, which must be avoided whenever possible. For example, if the image source is a blob or an image element, the decoded image may already be available in premultipled form. Rather than divide the already decoded data, the user agent must re-decode the image without premultiplying, thus ensuring that the ImageBitmap is delivered with the highest quality data.&amp;lt;/p&amp;gt;&amp;lt;p&amp;gt;Image sources that do not have an alpha channel are not affected by this option.&amp;lt;/p&amp;gt;&amp;lt;p&amp;gt;Caution: Canvases are assumed to be premultiplied image sources, which may not always be accurate.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Other potentially useful options ====&lt;br /&gt;
* enum imageOrientation, &#039;topLeft&#039; and &#039;bottomLeft&#039; &amp;lt;blockquote&amp;gt;&amp;lt;p&amp;gt;&#039;topLeft&#039;:  identify visual orientation from image media meta data and re-order data so top-down, left-to-right processing for display results in correct visual orientation. If the image source is an ImageBitmap, the image data will be flipped vertically if and only if the source was created with bottomLeft orientation. If the image source holds no orientation information, the image orientation is not changed.&amp;lt;/p&amp;gt;&amp;lt;p&amp;gt;&#039;bottomLeft&#039;: identify visual orientation from image media meta data and re-order data so bottom-up, left-to-right processing for display results in correct visual orientation. If the image source is an ImageBitmap, the image data will be flipped vertically if and only if the source was created with topLeft orientation. If the image source holds no orientation information, the image is flipped vertically.&amp;lt;/p&amp;gt;&amp;lt;blockquote&amp;gt; &lt;br /&gt;
* DOMString? crossOrigin: The crossOrigin option is a [[https://html.spec.whatwg.org/multipage/infrastructure.html#cors-settings-attribute CORS settings attribute]]. It is consulted when [[ImageBitmap Constructor taking URL|constructing an ImageBitmap from the URL of an image]]. Because ImageBitmaps can only be constructed from same-origin resources, in order to construct an ImageBitmap from the URL of a cross-origin image resource, the crossOrigin option must be specified, and the server must grant the request. Otherwise the Promise returned from createImageBitmap will be rejected.&lt;br /&gt;
* resizedWidth, resizedHeight: dimension to which the image should be resized. Could also be expressed using scale factors&lt;br /&gt;
* resizeFilter: filtering method used for scaling the image (pixelated, low quality, high quality, etc.)&lt;br /&gt;
* frameIndex: for creating an image bitmap from multi-frame image media&lt;br /&gt;
* flipX: like flipY but horizontal&lt;br /&gt;
* colorspace: to decode images to a colorspace other than the device colorspace (sRGB, Adobe RGB, YUV, YCbCr, etc.)&lt;br /&gt;
* custom color tranforms: color matrix, 3D Look up tables, per component look up tables, bias, gain, ... &lt;br /&gt;
&lt;br /&gt;
==== Processing Model ====&lt;br /&gt;
: These options affect the internal color representation used to store the ImageBitmap&#039;s bitmap data. The only observable effects would be on color fidelity. There would be no re-interpretation of color values. This is important because treating unpremultiplied colors as premultiplied is evil. For example, in blink&#039;s implementation, setting both options to &#039;none&#039; would have no side-effects on the graphical results of CanvasRenderingContext2D.drawImage(). The only difference would be that the color-space conversion and the multiplication by alpha would be deferred to drawImage(), instead of being applied during ImageBitmap creation. The usefulness of &#039;none&#039; is strictly for preventing losses in precision and gamut that may result from dividing by alpha and/or reversing the default color-space conversion when using APIs that would require it (WebGL&#039;s UNPACK_PREMULTIPLY_ALPHA_WEBGL and UNPACK_COLORSPACE_CONVERSION_WEBGL pixel storage parameters)&lt;br /&gt;
&lt;br /&gt;
==== Limitations ==== &lt;br /&gt;
: TBD &#039;&#039;Cases not covered by this solution in relation to the problem description; other problems with this solution, if any.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
==== Implementation ==== &lt;br /&gt;
: TBD &#039;&#039;Description of how and why browser vendors would take advantage of this feature.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
==== Adoption ==== &lt;br /&gt;
* Easier to develop asychronous image resource loading and preparation&lt;br /&gt;
* Better performance that what can be implemented using current APIs&lt;br /&gt;
* Applications can rely on the browser resource management facilities for caching decoded image data with the desired options baked-in and for evicting pre-decoded resources in low memory conditions to avoid out-of-memory crashes.&lt;br /&gt;
&lt;br /&gt;
==== See Also ====&lt;br /&gt;
&lt;br /&gt;
Related is the [[ImageBitmap Constructor taking URL]].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Proposals]]&lt;/div&gt;</summary>
		<author><name>Xidachen</name></author>
	</entry>
	<entry>
		<id>https://wiki.whatwg.org/index.php?title=ImageBitmap_Options&amp;diff=10029</id>
		<title>ImageBitmap Options</title>
		<link rel="alternate" type="text/html" href="https://wiki.whatwg.org/index.php?title=ImageBitmap_Options&amp;diff=10029"/>
		<updated>2016-02-08T19:50:54Z</updated>

		<summary type="html">&lt;p&gt;Xidachen: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
This page is a Work in Progress&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Problem to be solved&#039;&#039;&#039;: Loading and preparing image resources for rendering to 2D canvas contexts and WebGL contexts is often inefficient using existing APIs.&lt;br /&gt;
&lt;br /&gt;
== Use Case Description ==&lt;br /&gt;
:WebGL applications often use image media for transferring non-image data (illumination maps, vector maps, etc.) For such applications the image data must usually be decoded without colorspace conversions and without alpha premultiplications.&lt;br /&gt;
&lt;br /&gt;
=== Current Usage and Workarounds ===&lt;br /&gt;
&lt;br /&gt;
:Currently, there are several ways to apply arbitrary transformations on the client side, many of which involve intermediate copies of the image data. Some solutions involve DataURLs, temporary canvases, or direct manipulation of image data arrays, which are inefficient. Preparing the resources asynchronously also presents an additional challenge to the web developer.&lt;br /&gt;
&lt;br /&gt;
:WebGL applications can request that colorspace conversions be skipped at texture upload time by specifying pixel storage parameters, but this currently causes a synchronous image decode, because it is not known in advance that the image will need to be decoded in a special way. This latency is a significant problem for applications that upload many images to the GPU, such as Google Maps.&lt;br /&gt;
&lt;br /&gt;
:ImageBitmap offers an opportunity to provide exactly the desired image decoding options when the image is fetched, so that when the ImageBitmap is ready, it is in exactly the desired form for upload to the GPU.&lt;br /&gt;
&lt;br /&gt;
=== Benefits ===&lt;br /&gt;
&lt;br /&gt;
:With the right API support, image resources can be prepared asynchronously and/or in advance to avoid rendering latency issues. Furthermore, the preparation steps could be performed by native code, and in many case they can be integrated directly into the image decoding step without any additional memory consumption and little or no additional computational burden.&lt;br /&gt;
&lt;br /&gt;
=== Requests for this Feature ===&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;cite&amp;gt;[https://lists.w3.org/Archives/Public/public-whatwg-archive/2013Jun/0114.html June 2013 whatwg thread]&amp;lt;/cite&amp;gt;&lt;br /&gt;
* &amp;lt;cite&amp;gt;[https://lists.w3.org/Archives/Public/public-whatwg-archive/2013Jul/0075.html July 2013 whatwg thread]&amp;lt;/cite&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Proposed Solutions ==&lt;br /&gt;
&lt;br /&gt;
=== ImageBitmap Construction Options ===&lt;br /&gt;
&lt;br /&gt;
:Add an optional &#039;&#039;options&#039;&#039; argument to createImageBitmap to specify image treatments to be applied when creating the ImageBitmap object.&lt;br /&gt;
&lt;br /&gt;
==== Strongly desired options ====&lt;br /&gt;
&lt;br /&gt;
* enum imageOrientation, default = &#039;none&#039; &amp;lt;blockquote&amp;gt;&amp;lt;p&amp;gt;&#039;none&#039;: Do not change orientation.&amp;lt;/p&amp;gt;&amp;lt;p&amp;gt;&#039;flipY&#039;: Flip image vertically, disregarding image orientation meta data (EXIF or other), if any.&amp;lt;/p&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
* enum colorspaceConversion, default = &#039;default&#039; &amp;lt;blockquote&amp;gt;&amp;lt;p&amp;gt;&#039;none&#039;: The ImageBitmap must be created by decoding the source image media without performing any colorspace conversions. This means that the image decoding algorithm must ignore color profile meta-data embedded in the image source as well as the display device color profile.  colorspaceConversion only applies when creating ImageBitmaps from bitmap media data (i.e. blobs and image elements with non-vector images)&amp;lt;/p&amp;gt; &amp;lt;p&amp;gt;&#039;default&#039;: Implementation-specific behavior, possibly optimized for the implementation&#039;s graphics framework.&amp;lt;/p&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
* enum premultiplyAlpha, default = &#039;default&#039; &amp;lt;blockquote&amp;gt;&amp;lt;p&amp;gt;&#039;none&#039;: Image sources that are premultiplied by alpha will have their color components divided by alpha and image sources that are not premultiplied will be left untouched.&amp;lt;/p&amp;gt;&amp;lt;p&amp;gt;&#039;default&#039;: Implementation-specific behavior, possibly optimized for the implementation&#039;s graphics framework.&amp;lt;/p&amp;gt;&amp;lt;p&amp;gt;When premultiplyAlpha is set to &#039;none&#039;, the division by alpha may result in loss of precision, which must be avoided whenever possible. For example, if the image source is a blob or an image element, the decoded image may already be available in premultipled form. Rather than divide the already decoded data, the user agent must re-decode the image without premultiplying, thus ensuring that the ImageBitmap is delivered with the highest quality data.&amp;lt;/p&amp;gt;&amp;lt;p&amp;gt;Image sources that do not have an alpha channel are not affected by this option.&amp;lt;/p&amp;gt;&amp;lt;p&amp;gt;Caution: Canvases are assumed to be premultiplied image sources, which may not always be accurate.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Other potentially useful options ====&lt;br /&gt;
* enum imageOrientation, &#039;topLeft&#039; and &#039;bottomLeft&#039; &amp;lt;blockquote&amp;gt;&amp;lt;p&amp;gt;&#039;topLeft&#039;:  identify visual orientation from image media meta data and re-order data so top-down, left-to-right processing for display results in correct visual orientation. If the image source is an ImageBitmap, the image data will be flipped vertically if and only if the source was created with bottomLeft orientation. If the image source holds no orientation information, the image orientation is not changed.&amp;lt;/p&amp;gt;&amp;lt;p&amp;gt;&#039;bottomLeft&#039;: identify visual orientation from image media meta data and re-order data so bottom-up, left-to-right processing for display results in correct visual orientation. If the image source is an ImageBitmap, the image data will be flipped vertically if and only if the source was created with topLeft orientation. If the image source holds no orientation information, the image is flipped vertically.&amp;lt;/p&amp;gt;&amp;lt;blockquote&amp;gt; &lt;br /&gt;
* DOMString? crossOrigin: The crossOrigin option is a [[https://html.spec.whatwg.org/multipage/infrastructure.html#cors-settings-attribute CORS settings attribute]]. It is consulted when [[ImageBitmap Constructor taking URL|constructing an ImageBitmap from the URL of an image]]. Because ImageBitmaps can only be constructed from same-origin resources, in order to construct an ImageBitmap from the URL of a cross-origin image resource, the crossOrigin option must be specified, and the server must grant the request. Otherwise the Promise returned from createImageBitmap will be rejected.&lt;br /&gt;
* resizedWidth, resizedHeight: dimension to which the image should be resized. Could also be expressed using scale factors&lt;br /&gt;
* resizeFilter: filtering method used for scaling the image (pixelated, low quality, high quality, etc.)&lt;br /&gt;
* frameIndex: for creating an image bitmap from multi-frame image media&lt;br /&gt;
* flipX: like flipY but horizontal&lt;br /&gt;
* colorspace: to decode images to a colorspace other than the device colorspace (sRGB, Adobe RGB, YUV, YCbCr, etc.)&lt;br /&gt;
* custom color tranforms: color matrix, 3D Look up tables, per component look up tables, bias, gain, ... &lt;br /&gt;
&lt;br /&gt;
==== Processing Model ====&lt;br /&gt;
: These options affect the internal color representation used to store the ImageBitmap&#039;s bitmap data. The only observable effects would be on color fidelity. There would be no re-interpretation of color values. This is important because treating unpremultiplied colors as premultiplied is evil. For example, in blink&#039;s implementation, setting both options to &#039;none&#039; would have no side-effects on the graphical results of CanvasRenderingContext2D.drawImage(). The only difference would be that the color-space conversion and the multiplication by alpha would be deferred to drawImage(), instead of being applied during ImageBitmap creation. The usefulness of &#039;none&#039; is strictly for preventing losses in precision and gamut that may result from dividing by alpha and/or reversing the default color-space conversion when using APIs that would require it (WebGL&#039;s UNPACK_PREMULTIPLY_ALPHA_WEBGL and UNPACK_COLORSPACE_CONVERSION_WEBGL pixel storage parameters)&lt;br /&gt;
&lt;br /&gt;
==== Limitations ==== &lt;br /&gt;
: TBD &#039;&#039;Cases not covered by this solution in relation to the problem description; other problems with this solution, if any.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
==== Implementation ==== &lt;br /&gt;
: TBD &#039;&#039;Description of how and why browser vendors would take advantage of this feature.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
==== Adoption ==== &lt;br /&gt;
* Easier to develop asychronous image resource loading and preparation&lt;br /&gt;
* Better performance that what can be implemented using current APIs&lt;br /&gt;
* Applications can rely on the browser resource management facilities for caching decoded image data with the desired options baked-in and for evicting pre-decoded resources in low memory conditions to avoid out-of-memory crashes.&lt;br /&gt;
&lt;br /&gt;
==== See Also ====&lt;br /&gt;
&lt;br /&gt;
Related is the [[ImageBitmap Constructor taking URL]].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Proposals]]&lt;/div&gt;</summary>
		<author><name>Xidachen</name></author>
	</entry>
	<entry>
		<id>https://wiki.whatwg.org/index.php?title=ImageBitmap_Options&amp;diff=10028</id>
		<title>ImageBitmap Options</title>
		<link rel="alternate" type="text/html" href="https://wiki.whatwg.org/index.php?title=ImageBitmap_Options&amp;diff=10028"/>
		<updated>2016-02-05T19:40:26Z</updated>

		<summary type="html">&lt;p&gt;Xidachen: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
This page is a Work in Progress&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Problem to be solved&#039;&#039;&#039;: Loading and preparing image resources for rendering to 2D canvas contexts and WebGL contexts is often inefficient using existing APIs.&lt;br /&gt;
&lt;br /&gt;
== Use Case Description ==&lt;br /&gt;
:WebGL applications often use image media for transferring non-image data (illumination maps, vector maps, etc.) For such applications the image data must usually be decoded without colorspace conversions and without alpha premultiplications.&lt;br /&gt;
&lt;br /&gt;
=== Current Usage and Workarounds ===&lt;br /&gt;
&lt;br /&gt;
:Currently, there are several ways to apply arbitrary transformations on the client side, many of which involve intermediate copies of the image data. Some solutions involve DataURLs, temporary canvases, or direct manipulation of image data arrays, which are inefficient. Preparing the resources asynchronously also presents an additional challenge to the web developer.&lt;br /&gt;
&lt;br /&gt;
:WebGL applications can request that colorspace conversions be skipped at texture upload time by specifying pixel storage parameters, but this currently causes a synchronous image decode, because it is not known in advance that the image will need to be decoded in a special way. This latency is a significant problem for applications that upload many images to the GPU, such as Google Maps.&lt;br /&gt;
&lt;br /&gt;
:ImageBitmap offers an opportunity to provide exactly the desired image decoding options when the image is fetched, so that when the ImageBitmap is ready, it is in exactly the desired form for upload to the GPU.&lt;br /&gt;
&lt;br /&gt;
=== Benefits ===&lt;br /&gt;
&lt;br /&gt;
:With the right API support, image resources can be prepared asynchronously and/or in advance to avoid rendering latency issues. Furthermore, the preparation steps could be performed by native code, and in many case they can be integrated directly into the image decoding step without any additional memory consumption and little or no additional computational burden.&lt;br /&gt;
&lt;br /&gt;
=== Requests for this Feature ===&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;cite&amp;gt;[https://lists.w3.org/Archives/Public/public-whatwg-archive/2013Jun/0114.html June 2013 whatwg thread]&amp;lt;/cite&amp;gt;&lt;br /&gt;
* &amp;lt;cite&amp;gt;[https://lists.w3.org/Archives/Public/public-whatwg-archive/2013Jul/0075.html July 2013 whatwg thread]&amp;lt;/cite&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Proposed Solutions ==&lt;br /&gt;
&lt;br /&gt;
=== ImageBitmap Construction Options ===&lt;br /&gt;
&lt;br /&gt;
:Add an optional &#039;&#039;options&#039;&#039; argument to createImageBitmap to specify image treatments to be applied when creating the ImageBitmap object.&lt;br /&gt;
&lt;br /&gt;
==== Strongly desired options ====&lt;br /&gt;
&lt;br /&gt;
* enum imageOrientation, default = &#039;none&#039; &amp;lt;blockquote&amp;gt;&amp;lt;p&amp;gt;(Higher priority) &#039;none&#039;: Do not change orientation.&amp;lt;/p&amp;gt;&amp;lt;p&amp;gt;(Higher priority) &#039;flipY&#039;: Flip image vertically, disregarding image orientation meta data (EXIF or other), if any.&amp;lt;/p&amp;gt;&amp;lt;p&amp;gt;(Lower priority) &#039;topLeft&#039;:  identify visual orientation from image media meta data and re-order data so top-down, left-to-right processing for display results in correct visual orientation. If the image source is an ImageBitmap, the image data will be flipped vertically if and only if the source was created with bottomLeft orientation. If the image source holds no orientation information, the image orientation is not changed.&amp;lt;/p&amp;gt;&amp;lt;p&amp;gt;(Lower priority) &#039;bottomLeft&#039;: identify visual orientation from image media meta data and re-order data so bottom-up, left-to-right processing for display results in correct visual orientation. If the image source is an ImageBitmap, the image data will be flipped vertically if and only if the source was created with topLeft orientation. If the image source holds no orientation information, the image is flipped vertically.&amp;lt;/p&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
* enum colorspaceConversion, default = &#039;default&#039; &amp;lt;blockquote&amp;gt;&amp;lt;p&amp;gt;&#039;none&#039;: The ImageBitmap must be created by decoding the source image media without performing any colorspace conversions. This means that the image decoding algorithm must ignore color profile meta-data embedded in the image source as well as the display device color profile.  colorspaceConversion only applies when creating ImageBitmaps from bitmap media data (i.e. blobs and image elements with non-vector images)&amp;lt;/p&amp;gt; &amp;lt;p&amp;gt;&#039;default&#039;: Implementation-specific behavior, possibly optimized for the implementation&#039;s graphics framework.&amp;lt;/p&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
* enum premultiplyAlpha, default = &#039;default&#039; &amp;lt;blockquote&amp;gt;&amp;lt;p&amp;gt;&#039;none&#039;: Image sources that are premultiplied by alpha will have their color components divided by alpha and image sources that are not premultiplied will be left untouched.&amp;lt;/p&amp;gt;&amp;lt;p&amp;gt;&#039;default&#039;: Implementation-specific behavior, possibly optimized for the implementation&#039;s graphics framework.&amp;lt;/p&amp;gt;&amp;lt;p&amp;gt;When premultiplyAlpha is set to &#039;none&#039;, the division by alpha may result in loss of precision, which must be avoided whenever possible. For example, if the image source is a blob or an image element, the decoded image may already be available in premultipled form. Rather than divide the already decoded data, the user agent must re-decode the image without premultiplying, thus ensuring that the ImageBitmap is delivered with the highest quality data.&amp;lt;/p&amp;gt;&amp;lt;p&amp;gt;Image sources that do not have an alpha channel are not affected by this option.&amp;lt;/p&amp;gt;&amp;lt;p&amp;gt;Caution: Canvases are assumed to be premultiplied image sources, which may not always be accurate.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Other potentially useful options ====&lt;br /&gt;
* DOMString? crossOrigin: The crossOrigin option is a [[https://html.spec.whatwg.org/multipage/infrastructure.html#cors-settings-attribute CORS settings attribute]]. It is consulted when [[ImageBitmap Constructor taking URL|constructing an ImageBitmap from the URL of an image]]. Because ImageBitmaps can only be constructed from same-origin resources, in order to construct an ImageBitmap from the URL of a cross-origin image resource, the crossOrigin option must be specified, and the server must grant the request. Otherwise the Promise returned from createImageBitmap will be rejected.&lt;br /&gt;
* resizedWidth, resizedHeight: dimension to which the image should be resized. Could also be expressed using scale factors&lt;br /&gt;
* resizeFilter: filtering method used for scaling the image (pixelated, low quality, high quality, etc.)&lt;br /&gt;
* frameIndex: for creating an image bitmap from multi-frame image media&lt;br /&gt;
* flipX: like flipY but horizontal&lt;br /&gt;
* colorspace: to decode images to a colorspace other than the device colorspace (sRGB, Adobe RGB, YUV, YCbCr, etc.)&lt;br /&gt;
* custom color tranforms: color matrix, 3D Look up tables, per component look up tables, bias, gain, ... &lt;br /&gt;
&lt;br /&gt;
==== Processing Model ====&lt;br /&gt;
: These options affect the internal color representation used to store the ImageBitmap&#039;s bitmap data. The only observable effects would be on color fidelity. There would be no re-interpretation of color values. This is important because treating unpremultiplied colors as premultiplied is evil. For example, in blink&#039;s implementation, setting both options to &#039;none&#039; would have no side-effects on the graphical results of CanvasRenderingContext2D.drawImage(). The only difference would be that the color-space conversion and the multiplication by alpha would be deferred to drawImage(), instead of being applied during ImageBitmap creation. The usefulness of &#039;none&#039; is strictly for preventing losses in precision and gamut that may result from dividing by alpha and/or reversing the default color-space conversion when using APIs that would require it (WebGL&#039;s UNPACK_PREMULTIPLY_ALPHA_WEBGL and UNPACK_COLORSPACE_CONVERSION_WEBGL pixel storage parameters)&lt;br /&gt;
&lt;br /&gt;
==== Limitations ==== &lt;br /&gt;
: TBD &#039;&#039;Cases not covered by this solution in relation to the problem description; other problems with this solution, if any.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
==== Implementation ==== &lt;br /&gt;
: TBD &#039;&#039;Description of how and why browser vendors would take advantage of this feature.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
==== Adoption ==== &lt;br /&gt;
* Easier to develop asychronous image resource loading and preparation&lt;br /&gt;
* Better performance that what can be implemented using current APIs&lt;br /&gt;
* Applications can rely on the browser resource management facilities for caching decoded image data with the desired options baked-in and for evicting pre-decoded resources in low memory conditions to avoid out-of-memory crashes.&lt;br /&gt;
&lt;br /&gt;
==== See Also ====&lt;br /&gt;
&lt;br /&gt;
Related is the [[ImageBitmap Constructor taking URL]].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Proposals]]&lt;/div&gt;</summary>
		<author><name>Xidachen</name></author>
	</entry>
	<entry>
		<id>https://wiki.whatwg.org/index.php?title=ImageBitmap_Options&amp;diff=10027</id>
		<title>ImageBitmap Options</title>
		<link rel="alternate" type="text/html" href="https://wiki.whatwg.org/index.php?title=ImageBitmap_Options&amp;diff=10027"/>
		<updated>2016-02-04T15:47:06Z</updated>

		<summary type="html">&lt;p&gt;Xidachen: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
This page is a Work in Progress&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Problem to be solved&#039;&#039;&#039;: Loading and preparing image resources for rendering to 2D canvas contexts and WebGL contexts is often inefficient using existing APIs.&lt;br /&gt;
&lt;br /&gt;
== Use Case Description ==&lt;br /&gt;
:WebGL applications often use image media for transferring non-image data (illumination maps, vector maps, etc.) For such applications the image data must usually be decoded without colorspace conversions and without alpha premultiplications.&lt;br /&gt;
&lt;br /&gt;
=== Current Usage and Workarounds ===&lt;br /&gt;
&lt;br /&gt;
:Currently, there are several ways to apply arbitrary transformations on the client side, many of which involve intermediate copies of the image data. Some solutions involve DataURLs, temporary canvases, or direct manipulation of image data arrays, which are inefficient. Preparing the resources asynchronously also presents an additional challenge to the web developer.&lt;br /&gt;
&lt;br /&gt;
:WebGL applications can request that colorspace conversions be skipped at texture upload time by specifying pixel storage parameters, but this currently causes a synchronous image decode, because it is not known in advance that the image will need to be decoded in a special way. This latency is a significant problem for applications that upload many images to the GPU, such as Google Maps.&lt;br /&gt;
&lt;br /&gt;
:ImageBitmap offers an opportunity to provide exactly the desired image decoding options when the image is fetched, so that when the ImageBitmap is ready, it is in exactly the desired form for upload to the GPU.&lt;br /&gt;
&lt;br /&gt;
=== Benefits ===&lt;br /&gt;
&lt;br /&gt;
:With the right API support, image resources can be prepared asynchronously and/or in advance to avoid rendering latency issues. Furthermore, the preparation steps could be performed by native code, and in many case they can be integrated directly into the image decoding step without any additional memory consumption and little or no additional computational burden.&lt;br /&gt;
&lt;br /&gt;
=== Requests for this Feature ===&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;cite&amp;gt;[http://lists.whatwg.org/pipermail/whatwg-whatwg.org/2013-June/039793.html June 2013 whatwg thread]&amp;lt;/cite&amp;gt;&lt;br /&gt;
* &amp;lt;cite&amp;gt;[http://lists.whatwg.org/pipermail/whatwg-whatwg.org/2013-July/039983.html July 2013 whatwg thread]&amp;lt;/cite&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Proposed Solutions ==&lt;br /&gt;
&lt;br /&gt;
=== ImageBitmap Construction Options ===&lt;br /&gt;
&lt;br /&gt;
:Add an optional &#039;&#039;options&#039;&#039; argument to createImageBitmap to specify image treatments to be applied when creating the ImageBitmap object.&lt;br /&gt;
&lt;br /&gt;
==== Strongly desired options ====&lt;br /&gt;
&lt;br /&gt;
* enum imageOrientation, default = &#039;none&#039; &amp;lt;blockquote&amp;gt;&amp;lt;p&amp;gt;(Higher priority) &#039;none&#039;: Do not change orientation.&amp;lt;/p&amp;gt;&amp;lt;p&amp;gt;(Higher priority) &#039;flipY&#039;: Flip image vertically, disregarding image orientation meta data (EXIF or other), if any.&amp;lt;/p&amp;gt;&amp;lt;p&amp;gt;(Lower priority) &#039;topLeft&#039;:  identify visual orientation from image media meta data and re-order data so top-down, left-to-right processing for display results in correct visual orientation. If the image source is an ImageBitmap, the image data will be flipped vertically if and only if the source was created with bottomLeft orientation. If the image source holds no orientation information, the image orientation is not changed.&amp;lt;/p&amp;gt;&amp;lt;p&amp;gt;(Lower priority) &#039;bottomLeft&#039;: identify visual orientation from image media meta data and re-order data so bottom-up, left-to-right processing for display results in correct visual orientation. If the image source is an ImageBitmap, the image data will be flipped vertically if and only if the source was created with topLeft orientation. If the image source holds no orientation information, the image is flipped vertically.&amp;lt;/p&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
* enum colorspaceConversion, default = &#039;default&#039; &amp;lt;blockquote&amp;gt;&amp;lt;p&amp;gt;&#039;none&#039;: The ImageBitmap must be created by decoding the source image media without performing any colorspace conversions. This means that the image decoding algorithm must ignore color profile meta-data embedded in the image source as well as the display device color profile.  colorspaceConversion only applies when creating ImageBitmaps from bitmap media data (i.e. blobs and image elements with non-vector images)&amp;lt;/p&amp;gt; &amp;lt;p&amp;gt;&#039;default&#039;: Implementation-specific behavior, possibly optimized for the implementation&#039;s graphics framework.&amp;lt;/p&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
* enum premultiplyAlpha, default = &#039;default&#039; &amp;lt;blockquote&amp;gt;&amp;lt;p&amp;gt;&#039;none&#039;: Image sources that are premultiplied by alpha will have their color components divided by alpha and image sources that are not premultiplied will be left untouched.&amp;lt;/p&amp;gt;&amp;lt;p&amp;gt;&#039;default&#039;: Implementation-specific behavior, possibly optimized for the implementation&#039;s graphics framework.&amp;lt;/p&amp;gt;&amp;lt;p&amp;gt;When premultiplyAlpha is set to &#039;none&#039;, the division by alpha may result in loss of precision, which must be avoided whenever possible. For example, if the image source is a blob or an image element, the decoded image may already be available in premultipled form. Rather than divide the already decoded data, the user agent must re-decode the image without premultiplying, thus ensuring that the ImageBitmap is delivered with the highest quality data.&amp;lt;/p&amp;gt;&amp;lt;p&amp;gt;Image sources that do not have an alpha channel are not affected by this option.&amp;lt;/p&amp;gt;&amp;lt;p&amp;gt;Caution: Canvases are assumed to be premultiplied image sources, which may not always be accurate.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Other potentially useful options ====&lt;br /&gt;
* DOMString? crossOrigin: The crossOrigin option is a [[https://html.spec.whatwg.org/multipage/infrastructure.html#cors-settings-attribute CORS settings attribute]]. It is consulted when [[ImageBitmap Constructor taking URL|constructing an ImageBitmap from the URL of an image]]. Because ImageBitmaps can only be constructed from same-origin resources, in order to construct an ImageBitmap from the URL of a cross-origin image resource, the crossOrigin option must be specified, and the server must grant the request. Otherwise the Promise returned from createImageBitmap will be rejected.&lt;br /&gt;
* resizedWidth, resizedHeight: dimension to which the image should be resized. Could also be expressed using scale factors&lt;br /&gt;
* resizeFilter: filtering method used for scaling the image (pixelated, low quality, high quality, etc.)&lt;br /&gt;
* frameIndex: for creating an image bitmap from multi-frame image media&lt;br /&gt;
* flipX: like flipY but horizontal&lt;br /&gt;
* colorspace: to decode images to a colorspace other than the device colorspace (sRGB, Adobe RGB, YUV, YCbCr, etc.)&lt;br /&gt;
* custom color tranforms: color matrix, 3D Look up tables, per component look up tables, bias, gain, ... &lt;br /&gt;
&lt;br /&gt;
==== Processing Model ====&lt;br /&gt;
: These options affect the internal color representation used to store the ImageBitmap&#039;s bitmap data. The only observable effects would be on color fidelity. There would be no re-interpretation of color values. This is important because treating unpremultiplied colors as premultiplied is evil. For example, in blink&#039;s implementation, setting both options to &#039;none&#039; would have no side-effects on the graphical results of CanvasRenderingContext2D.drawImage(). The only difference would be that the color-space conversion and the multiplication by alpha would be deferred to drawImage(), instead of being applied during ImageBitmap creation. The usefulness of &#039;none&#039; is strictly for preventing losses in precision and gamut that may result from dividing by alpha and/or reversing the default color-space conversion when using APIs that would require it (WebGL&#039;s UNPACK_PREMULTIPLY_ALPHA_WEBGL and UNPACK_COLORSPACE_CONVERSION_WEBGL pixel storage parameters)&lt;br /&gt;
&lt;br /&gt;
==== Limitations ==== &lt;br /&gt;
: TBD &#039;&#039;Cases not covered by this solution in relation to the problem description; other problems with this solution, if any.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
==== Implementation ==== &lt;br /&gt;
: TBD &#039;&#039;Description of how and why browser vendors would take advantage of this feature.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
==== Adoption ==== &lt;br /&gt;
* Easier to develop asychronous image resource loading and preparation&lt;br /&gt;
* Better performance that what can be implemented using current APIs&lt;br /&gt;
* Applications can rely on the browser resource management facilities for caching decoded image data with the desired options baked-in and for evicting pre-decoded resources in low memory conditions to avoid out-of-memory crashes.&lt;br /&gt;
&lt;br /&gt;
==== See Also ====&lt;br /&gt;
&lt;br /&gt;
Related is the [[ImageBitmap Constructor taking URL]].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Proposals]]&lt;/div&gt;</summary>
		<author><name>Xidachen</name></author>
	</entry>
	<entry>
		<id>https://wiki.whatwg.org/index.php?title=ImageBitmap_Options&amp;diff=10026</id>
		<title>ImageBitmap Options</title>
		<link rel="alternate" type="text/html" href="https://wiki.whatwg.org/index.php?title=ImageBitmap_Options&amp;diff=10026"/>
		<updated>2016-02-04T03:17:22Z</updated>

		<summary type="html">&lt;p&gt;Xidachen: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
This page is a Work in Progress&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Problem to be solved&#039;&#039;&#039;: Loading and preparing image resources for rendering to 2D canvas contexts and WebGL contexts is often inefficient using existing APIs.&lt;br /&gt;
&lt;br /&gt;
== Use Case Description ==&lt;br /&gt;
:WebGL applications often use image media for transferring non-image data (illumination maps, vector maps, etc.) For such applications the image data must usually be decoded without colorspace conversions and without alpha premultiplications.&lt;br /&gt;
&lt;br /&gt;
=== Current Usage and Workarounds ===&lt;br /&gt;
&lt;br /&gt;
:Currently, there are several ways to apply arbitrary transformations on the client side, many of which involve intermediate copies of the image data. Some solutions involve DataURLs, temporary canvases, or direct manipulation of image data arrays, which are inefficient. Preparing the resources asynchronously also presents an additional challenge to the web developer.&lt;br /&gt;
&lt;br /&gt;
:WebGL applications can request that colorspace conversions be skipped at texture upload time by specifying pixel storage parameters, but this currently causes a synchronous image decode, because it is not known in advance that the image will need to be decoded in a special way. This latency is a significant problem for applications that upload many images to the GPU, such as Google Maps.&lt;br /&gt;
&lt;br /&gt;
:ImageBitmap offers an opportunity to provide exactly the desired image decoding options when the image is fetched, so that when the ImageBitmap is ready, it is in exactly the desired form for upload to the GPU.&lt;br /&gt;
&lt;br /&gt;
=== Benefits ===&lt;br /&gt;
&lt;br /&gt;
:With the right API support, image resources can be prepared asynchronously and/or in advance to avoid rendering latency issues. Furthermore, the preparation steps could be performed by native code, and in many case they can be integrated directly into the image decoding step without any additional memory consumption and little or no additional computational burden.&lt;br /&gt;
&lt;br /&gt;
=== Requests for this Feature ===&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;cite&amp;gt;[http://lists.whatwg.org/pipermail/whatwg-whatwg.org/2013-June/039793.html June 2013 whatwg thread]&amp;lt;/cite&amp;gt;&lt;br /&gt;
* &amp;lt;cite&amp;gt;[http://lists.whatwg.org/pipermail/whatwg-whatwg.org/2013-July/039983.html July 2013 whatwg thread]&amp;lt;/cite&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Proposed Solutions ==&lt;br /&gt;
&lt;br /&gt;
=== ImageBitmap Construction Options ===&lt;br /&gt;
&lt;br /&gt;
:Add an optional &#039;&#039;options&#039;&#039; argument to createImageBitmap to specify image treatments to be applied when creating the ImageBitmap object.&lt;br /&gt;
&lt;br /&gt;
==== Strongly desired options ====&lt;br /&gt;
&lt;br /&gt;
* enum imageOrientation, default = &#039;none&#039; &amp;lt;blockquote&amp;gt;&amp;lt;p&amp;gt;(Higher priority) &#039;none&#039;: Do not change orientation.&amp;lt;/p&amp;gt;&amp;lt;p&amp;gt;(Higher priority) &#039;flipY&#039;: Flip image vertically, disregarding image orientation meta data (EXIF or other), if any.&amp;lt;/p&amp;gt;&amp;lt;p&amp;gt;(Lower priority) &#039;topLeft&#039;:  identify visual orientation from image media meta data and re-order data so top-down, left-to-right processing for display results in correct visual orientation. If the image source is an ImageBitmap, the image data will be flipped vertically if and only if the source was created with bottomLeft orientation. If the image source holds no orientation information, the image orientation is not changed.&amp;lt;/p&amp;gt;&amp;lt;p&amp;gt;(Lower priority) &#039;bottomLeft&#039;: identify visual orientation from image media meta data and re-order data so bottom-up, left-to-right processing for display results in correct visual orientation. If the image source is an ImageBitmap, the image data will be flipped vertically if and only if the source was created with topLeft orientation. If the image source holds no orientation information, the image is flipped vertically.&amp;lt;/p&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
* enum colorspaceConversion, default = &#039;default&#039; &amp;lt;blockquote&amp;gt;&amp;lt;p&amp;gt;&#039;none&#039;: The ImageBitmap must be created by decoding the source image media without performing any colorspace conversions. This means that the image decoding algorithm must ignore color profile meta-data embedded in the image source as well as the display device color profile.  colorspaceConversion only applies when creating ImageBitmaps from bitmap media data (i.e. blobs and image elements with non-vector images)&amp;lt;/p&amp;gt; &amp;lt;p&amp;gt;&#039;default&#039;: Implementation-specific behavior, possibly optimized for the implementation&#039;s graphics framework.&amp;lt;/p&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
* enum premultiplyAlpha, default = &#039;default&#039; &amp;lt;blockquote&amp;gt;&amp;lt;p&amp;gt;&#039;none&#039;: Image sources that are premultiplied by alpha will have their color components divided by alpha and image sources that are not premultiplied will be left untouched.&amp;lt;/p&amp;gt;&amp;lt;p&amp;gt;&#039;default&#039;: Implementation-specific behavior, possibly optimized for the implementation&#039;s graphics framework.&amp;lt;/p&amp;gt;&amp;lt;p&amp;gt;When premultiplyAlpha is set to &#039;none&#039;, the division by alpha may result in loss of precision, which must be avoided whenever possible. For example, if the image source is a blob or an image element, the decoded image may already be available in premultipled form. Rather than divide the already decoded data, the user agent must re-decode the image without premultiplying, thus ensuring that the ImageBitmap is delivered with the highest quality data.&amp;lt;/p&amp;gt;&amp;lt;p&amp;gt;Image sources that do not have an alpha channel are not affected by this option.&amp;lt;/p&amp;gt;&amp;lt;p&amp;gt;Caution: Canvases are assumed to be premultiplied image sources, which may not always be accurate.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
* DOMString? crossOrigin, default = null &amp;lt;blockquote&amp;gt;&amp;lt;p&amp;gt;The crossOrigin option is a [[https://html.spec.whatwg.org/multipage/infrastructure.html#cors-settings-attribute CORS settings attribute]]. It is consulted when [[ImageBitmap Constructor taking URL|constructing an ImageBitmap from the URL of an image]]. Because ImageBitmaps can only be constructed from same-origin resources, in order to construct an ImageBitmap from the URL of a cross-origin image resource, the crossOrigin option must be specified, and the server must grant the request. Otherwise the Promise returned from createImageBitmap will be rejected.&amp;lt;/p&amp;gt;&amp;lt;p&amp;gt;Compared with the previous three options, this option has relatively lower priority.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Other potentially useful options ====&lt;br /&gt;
&lt;br /&gt;
* resizedWidth, resizedHeight: dimension to which the image should be resized. Could also be expressed using scale factors&lt;br /&gt;
* resizeFilter: filtering method used for scaling the image (pixelated, low quality, high quality, etc.)&lt;br /&gt;
* frameIndex: for creating an image bitmap from multi-frame image media&lt;br /&gt;
* flipX: like flipY but horizontal&lt;br /&gt;
* colorspace: to decode images to a colorspace other than the device colorspace (sRGB, Adobe RGB, YUV, YCbCr, etc.)&lt;br /&gt;
* custom color tranforms: color matrix, 3D Look up tables, per component look up tables, bias, gain, ... &lt;br /&gt;
&lt;br /&gt;
==== Processing Model ====&lt;br /&gt;
: These options affect the internal color representation used to store the ImageBitmap&#039;s bitmap data. The only observable effects would be on color fidelity. There would be no re-interpretation of color values. This is important because treating unpremultiplied colors as premultiplied is evil. For example, in blink&#039;s implementation, setting both options to &#039;none&#039; would have no side-effects on the graphical results of CanvasRenderingContext2D.drawImage(). The only difference would be that the color-space conversion and the multiplication by alpha would be deferred to drawImage(), instead of being applied during ImageBitmap creation. The usefulness of &#039;none&#039; is strictly for preventing losses in precision and gamut that may result from dividing by alpha and/or reversing the default color-space conversion when using APIs that would require it (WebGL&#039;s UNPACK_PREMULTIPLY_ALPHA_WEBGL and UNPACK_COLORSPACE_CONVERSION_WEBGL pixel storage parameters)&lt;br /&gt;
&lt;br /&gt;
==== Limitations ==== &lt;br /&gt;
: TBD &#039;&#039;Cases not covered by this solution in relation to the problem description; other problems with this solution, if any.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
==== Implementation ==== &lt;br /&gt;
: TBD &#039;&#039;Description of how and why browser vendors would take advantage of this feature.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
==== Adoption ==== &lt;br /&gt;
* Easier to develop asychronous image resource loading and preparation&lt;br /&gt;
* Better performance that what can be implemented using current APIs&lt;br /&gt;
* Applications can rely on the browser resource management facilities for caching decoded image data with the desired options baked-in and for evicting pre-decoded resources in low memory conditions to avoid out-of-memory crashes.&lt;br /&gt;
&lt;br /&gt;
==== See Also ====&lt;br /&gt;
&lt;br /&gt;
Related is the [[ImageBitmap Constructor taking URL]].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Proposals]]&lt;/div&gt;</summary>
		<author><name>Xidachen</name></author>
	</entry>
	<entry>
		<id>https://wiki.whatwg.org/index.php?title=ImageBitmap_Options&amp;diff=10025</id>
		<title>ImageBitmap Options</title>
		<link rel="alternate" type="text/html" href="https://wiki.whatwg.org/index.php?title=ImageBitmap_Options&amp;diff=10025"/>
		<updated>2016-02-04T02:36:13Z</updated>

		<summary type="html">&lt;p&gt;Xidachen: First try on editing the imageOrientation option&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
This page is a Work in Progress&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Problem to be solved&#039;&#039;&#039;: Loading and preparing image resources for rendering to 2D canvas contexts and WebGL contexts is often inefficient using existing APIs.&lt;br /&gt;
&lt;br /&gt;
== Use Case Description ==&lt;br /&gt;
:WebGL applications often use image media for transferring non-image data (illumination maps, vector maps, etc.) For such applications the image data must usually be decoded without colorspace conversions and without alpha premultiplications.&lt;br /&gt;
&lt;br /&gt;
=== Current Usage and Workarounds ===&lt;br /&gt;
&lt;br /&gt;
:Currently, there are several ways to apply arbitrary transformations on the client side, many of which involve intermediate copies of the image data. Some solutions involve DataURLs, temporary canvases, or direct manipulation of image data arrays, which are inefficient. Preparing the resources asynchronously also presents an additional challenge to the web developer.&lt;br /&gt;
&lt;br /&gt;
:WebGL applications can request that colorspace conversions be skipped at texture upload time by specifying pixel storage parameters, but this currently causes a synchronous image decode, because it is not known in advance that the image will need to be decoded in a special way. This latency is a significant problem for applications that upload many images to the GPU, such as Google Maps.&lt;br /&gt;
&lt;br /&gt;
:ImageBitmap offers an opportunity to provide exactly the desired image decoding options when the image is fetched, so that when the ImageBitmap is ready, it is in exactly the desired form for upload to the GPU.&lt;br /&gt;
&lt;br /&gt;
=== Benefits ===&lt;br /&gt;
&lt;br /&gt;
:With the right API support, image resources can be prepared asynchronously and/or in advance to avoid rendering latency issues. Furthermore, the preparation steps could be performed by native code, and in many case they can be integrated directly into the image decoding step without any additional memory consumption and little or no additional computational burden.&lt;br /&gt;
&lt;br /&gt;
=== Requests for this Feature ===&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;cite&amp;gt;[http://lists.whatwg.org/pipermail/whatwg-whatwg.org/2013-June/039793.html June 2013 whatwg thread]&amp;lt;/cite&amp;gt;&lt;br /&gt;
* &amp;lt;cite&amp;gt;[http://lists.whatwg.org/pipermail/whatwg-whatwg.org/2013-July/039983.html July 2013 whatwg thread]&amp;lt;/cite&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Proposed Solutions ==&lt;br /&gt;
&lt;br /&gt;
=== ImageBitmap Construction Options ===&lt;br /&gt;
&lt;br /&gt;
:Add an optional &#039;&#039;options&#039;&#039; argument to createImageBitmap to specify image treatments to be applied when creating the ImageBitmap object.&lt;br /&gt;
&lt;br /&gt;
==== Strongly desired options ====&lt;br /&gt;
&lt;br /&gt;
* enum imageOrientation, default = &#039;none&#039; &amp;lt;blockquote&amp;gt;&amp;lt;p&amp;gt;(Higher priority) &#039;none&#039;: Do not change orientation.&amp;lt;/p&amp;gt;&amp;lt;p&amp;gt;(Higher priority) &#039;flipY&#039;: Flip image vertically, disregarding image orientation meta data (EXIF or other), if any.&amp;lt;/p&amp;gt;&amp;lt;p&amp;gt;(Lower priority) &#039;topLeft&#039;:  identify visual orientation from image media meta data and re-order data so top-down, left-to-right processing for display results in correct visual orientation. If the image source is an ImageBitmap, the image data will be flipped vertically if and only if the source was created with bottomLeft orientation. If the image source holds no orientation information, the image orientation is not changed.&amp;lt;/p&amp;gt;&amp;lt;p&amp;gt;(Lower priority) &#039;bottomLeft&#039;: identify visual orientation from image media meta data and re-order data so bottom-up, left-to-right processing for display results in correct visual orientation. If the image source is an ImageBitmap, the image data will be flipped vertically if and only if the source was created with topLeft orientation. If the image source holds no orientation information, the image is flipped vertically.&amp;lt;/p&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
* boolean colorspaceConversion, default = true &amp;lt;blockquote&amp;gt;&amp;lt;p&amp;gt;If set to false, the ImageBitmap must be created by decoding the source image media without performing any colorspace conversions. This means that the image decoding algorithm must ignore color profile meta-data embedded in the image source as well as the display device color profile.  colorspaceConversion only applies when creating ImageBitmaps from bitmap media data (i.e. blobs and image elements with non-vector images)&amp;lt;/p&amp;gt;&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
* boolean premultiplyAlpha, default = true &amp;lt;blockquote&amp;gt;&amp;lt;p&amp;gt;If set to false, image sources that are premultiplied by alpha will have their color components divided by alpha and image sources that are not premultiplied will be left untouched.&amp;lt;/p&amp;gt;&amp;lt;p&amp;gt;If set to true, image sources that are not premultiplied by alpha will have their color components multiplied by alpha and image sources that are premultiplied will be left untouched.&amp;lt;/p&amp;gt;&amp;lt;p&amp;gt;When premultiplyAlpha is set to false, the division by alpha may result in loss of precision, which must be avoided whenever possible. For example, if the image source is a blob or an image element, the decoded image may already be available in premultipled form. Rather than divide the already decoded data, the user agent must re-decode the image without premultiplying, thus ensuring that the ImageBitmap is delivered with the highest quality data.&amp;lt;/p&amp;gt;&amp;lt;p&amp;gt;Image sources that do not have an alpha channel are not affected by this option.&amp;lt;/p&amp;gt;&amp;lt;p&amp;gt;Caution: Canvases are assumed to be premultiplied image sources, which may not always be accurate.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
* DOMString? crossOrigin, default = null &amp;lt;blockquote&amp;gt;&amp;lt;p&amp;gt;The crossOrigin option is a [[https://html.spec.whatwg.org/multipage/infrastructure.html#cors-settings-attribute CORS settings attribute]]. It is consulted when [[ImageBitmap Constructor taking URL|constructing an ImageBitmap from the URL of an image]]. Because ImageBitmaps can only be constructed from same-origin resources, in order to construct an ImageBitmap from the URL of a cross-origin image resource, the crossOrigin option must be specified, and the server must grant the request. Otherwise the Promise returned from createImageBitmap will be rejected.&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Other potentially useful options ====&lt;br /&gt;
&lt;br /&gt;
* resizedWidth, resizedHeight: dimension to which the image should be resized. Could also be expressed using scale factors&lt;br /&gt;
* resizeFilter: filtering method used for scaling the image (pixelated, low quality, high quality, etc.)&lt;br /&gt;
* frameIndex: for creating an image bitmap from multi-frame image media&lt;br /&gt;
* flipX: like flipY but horizontal&lt;br /&gt;
* colorspace: to decode images to a colorspace other than the device colorspace (sRGB, Adobe RGB, YUV, YCbCr, etc.)&lt;br /&gt;
* custom color tranforms: color matrix, 3D Look up tables, per component look up tables, bias, gain, ... &lt;br /&gt;
&lt;br /&gt;
==== Processing Model ====&lt;br /&gt;
: TBD &#039;&#039;Explanation of the changes introduced by this solution. It explains how the document is processed, and how errors are handled. This should be very clear, including things such as event timing if the solution involves events, how to create graphs representing the data in the case of semantic proposals, etc.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
==== Limitations ==== &lt;br /&gt;
: TBD &#039;&#039;Cases not covered by this solution in relation to the problem description; other problems with this solution, if any.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
==== Implementation ==== &lt;br /&gt;
: TBD &#039;&#039;Description of how and why browser vendors would take advantage of this feature.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
==== Adoption ==== &lt;br /&gt;
* Easier to develop asychronous image resource loading and preparation&lt;br /&gt;
* Better performance that what can be implemented using current APIs&lt;br /&gt;
* Applications can rely on the browser resource management facilities for caching decoded image data with the desired options baked-in and for evicting pre-decoded resources in low memory conditions to avoid out-of-memory crashes.&lt;br /&gt;
&lt;br /&gt;
==== See Also ====&lt;br /&gt;
&lt;br /&gt;
Related is the [[ImageBitmap Constructor taking URL]].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Proposals]]&lt;/div&gt;</summary>
		<author><name>Xidachen</name></author>
	</entry>
</feed>