// Copyright © 2018 The CefSharp Authors. All rights reserved. // // Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. using CefSharp.Enums; namespace CefSharp { /// /// Container for a single image represented at different scale factors. /// All image representations should be the same size in density independent pixel (DIP) units. /// For example, if the image at scale factor 1.0 is 100x100 pixels then the image at scale factor 2.0 should be 200x200 pixels -- both images will display with a DIP size of 100x100 units. /// The methods of this class must be called on the browser process UI thread. /// public interface IImage { //Add a bitmap image representation for scaleFactor. //bool AddBitmap(float scaleFactor, int pixel_width, int pixel_height, cef_color_type_t color_type, cef_alpha_type_t alpha_type, const void* pixel_data, size_t pixel_data_size ); //Create a JPEG image representation for scaleFactor. //bool AddJPEG(float scaleFactor, const void* jpeg_data, size_t jpeg_data_size )= 0 //Add a PNG image representation for scaleFactor. //bool AddPNG(float scaleFactor, const void* png_data, size_t png_data_size )= 0 /// /// Returns the bitmap representation that most closely matches scaleFactor. /// /// scale factor /// color type /// alpha type /// pixel width /// pixel height /// A stream represending the bitmap or null. byte[] GetAsBitmap(float scaleFactor, ColorType colorType, AlphaType alphaType, out int pixelWidth, out int pixelHeight); /// /// Returns the JPEG representation that most closely matches scaleFactor. /// /// scale factor /// image quality /// pixel width /// pixel height /// A stream representing the JPEG or null. byte[] GetAsJPEG(float scaleFactor, int quality, out int pixelWidth, out int pixelHeight); /// /// Returns the PNG representation that most closely matches scaleFactor. /// /// scale factor /// is the PNG transparent /// pixel width /// pixel height /// A stream represending the PNG or null. byte[] GetAsPNG(float scaleFactor, bool withTransparency, out int pixelWidth, out int pixelHeight); /// /// Returns information for the representation that most closely matches scaleFactor. /// /// scale factor /// actual scale factor /// pixel width /// pixel height /// return if information found for scale factor bool GetRepresentationInfo(float scaleFactor, out float actualScaleFactor, out int pixelWidth, out int pixelHeight); /// /// Returns the image height in density independent pixel(DIP) units. /// int Height { get; } /// /// Returns true if this image contains a representation for scaleFactor. /// /// /// bool HasRepresentation(float scaleFactor); /// /// Returns true if this Image is empty. /// bool IsEmpty { get; } /// /// Returns true if this Image and that Image share the same underlying storage. /// /// image to compare /// returns true if share same underlying storage bool IsSame(IImage that); /// /// Removes the representation for scaleFactor. /// /// /// true for success bool RemoveRepresentation(float scaleFactor); /// /// Returns the image width in density independent pixel(DIP) units. /// int Width { get; } } }