admin
2020-06-10 a610f2ab6e543d2cb78c1ef212ac6a74ddc067d9
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
// 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
{
    /// <summary>
    /// 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. 
    /// </summary>
    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
 
        /// <summary>
        /// Returns the bitmap representation that most closely matches scaleFactor.
        /// </summary>
        /// <param name="scaleFactor">scale factor</param>
        /// <param name="colorType">color type</param>
        /// <param name="alphaType">alpha type</param>
        /// <param name="pixelWidth">pixel width</param>
        /// <param name="pixelHeight">pixel height</param>
        /// <returns>A stream represending the bitmap or null.</returns>
        byte[] GetAsBitmap(float scaleFactor, ColorType colorType, AlphaType alphaType, out int pixelWidth, out int pixelHeight);
 
        /// <summary>
        /// Returns the JPEG representation that most closely matches scaleFactor.
        /// </summary>
        /// <param name="scaleFactor">scale factor</param>
        /// <param name="quality">image quality</param>
        /// <param name="pixelWidth">pixel width</param>
        /// <param name="pixelHeight">pixel height</param>
        /// <returns>A stream representing the JPEG or null.</returns>
        byte[] GetAsJPEG(float scaleFactor, int quality, out int pixelWidth, out int pixelHeight);
 
        /// <summary>
        /// Returns the PNG representation that most closely matches scaleFactor.
        /// </summary>
        /// <param name="scaleFactor">scale factor</param>
        /// <param name="withTransparency">is the PNG transparent</param>
        /// <param name="pixelWidth">pixel width</param>
        /// <param name="pixelHeight">pixel height</param>
        /// <returns>A stream represending the PNG or null.</returns>
        byte[] GetAsPNG(float scaleFactor, bool withTransparency, out int pixelWidth, out int pixelHeight);
 
        /// <summary>
        /// Returns information for the representation that most closely matches scaleFactor.
        /// </summary>
        /// <param name="scaleFactor">scale factor</param>
        /// <param name="actualScaleFactor">actual scale factor</param>
        /// <param name="pixelWidth">pixel width</param>
        /// <param name="pixelHeight">pixel height</param>
        /// <returns>return if information found for scale factor</returns>
        bool GetRepresentationInfo(float scaleFactor, out float actualScaleFactor, out int pixelWidth, out int pixelHeight);
 
        /// <summary>
        /// Returns the image height in density independent pixel(DIP) units.
        /// </summary>
        int Height { get; }
 
        /// <summary>
        /// Returns true if this image contains a representation for scaleFactor.
        /// </summary>
        /// <param name="scaleFactor"></param>
        /// <returns></returns>
        bool HasRepresentation(float scaleFactor);
 
        /// <summary>
        /// Returns true if this Image is empty.
        /// </summary>
        bool IsEmpty { get; }
 
        /// <summary>
        /// Returns true if this Image and that Image share the same underlying storage.
        /// </summary>
        /// <param name="that">image to compare</param>
        /// <returns>returns true if share same underlying storage</returns>
        bool IsSame(IImage that);
 
        /// <summary>
        /// Removes the representation for scaleFactor.
        /// </summary>
        /// <param name="scaleFactor"></param>
        /// <returns>true for success</returns>
        bool RemoveRepresentation(float scaleFactor);
 
        /// <summary>
        /// Returns the image width in density independent pixel(DIP) units.
        /// </summary>
        int Width { get; }
    }
}