Esempio n. 1
0
        public static bool TryCreate(out SciterImage sciterImage, int width, int height, bool withAlpha)
        {
            var result = GraphicsApi.ImageCreate(out var imageHandle, System.Convert.ToUInt32(Math.Max(width, 0)), System.Convert.ToUInt32(Math.Max(height, 0)), withAlpha)
                         .IsOk();

            sciterImage = result ? new SciterImage(imageHandle: imageHandle) : default;
            return(result);
        }
Esempio n. 2
0
        /// <summary>
        /// <para>Loads image from RAW BGRA pixmap data</para>
        /// <para>Size of pixmap data is pixmapWidth * pixmapHeight*4
        /// construct image from B[n+0],G[n+1],R[n+2],A[n+3] data</para>
        /// </summary>
        public static bool TryCreate(out SciterImage sciterImage, IntPtr data, uint width, uint height, bool withAlpha)
        {
            var result = GraphicsApi.ImageCreateFromPixmap(out var imageHandle, width, height, withAlpha, data)
                         .IsOk();

            sciterImage = result ? new SciterImage(imageHandle: imageHandle) : default;
            return(result);
        }
Esempio n. 3
0
        /// <summary>
        /// Loads image from PNG or JPG image buffer
        /// </summary>
        public static bool TryCreate(out SciterImage sciterImage, byte[] data)
        {
            var result = GraphicsApi.ImageLoad(data, (uint)data.Length, out var imageHandle)
                         .IsOk();

            sciterImage = result ? new SciterImage(imageHandle: imageHandle) : default;
            return(result);
        }
Esempio n. 4
0
        public static bool TryCreate(out SciterImage sciterImage, SciterValue sciterValue)
        {
            var v      = sciterValue.ToVALUE();
            var result = GraphicsApi.ValueUnWrapImage(ref v, out var imageHandle)
                         .IsOk();

            sciterImage = result ? new SciterImage(imageHandle: imageHandle) : default;
            return(result);
        }
Esempio n. 5
0
 internal bool TryBlendImageInternal(SciterImage img, float x = 0f, float y = 0f)
 {
     //float w, h, ix, iy, iw, ih, opacity;
     return(GraphicsApi.GraphicsDrawImage(this.Handle, img.Handle, x, y, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero)
            .IsOk());
 }
Esempio n. 6
0
        /*DON'T KNOW IF IT WORKS AND IF YOU MUST CALL gAddRef()
         * SO NOT SAFE
         * public SciterGraphics(SciterImage img)
         * {
         *      var r = GraphicsApi.gCreate(img.Handle, out var gfx);
         *      Debug.Assert(r.IsOk());
         * }
         */

        internal void BlendImageInternal(SciterImage img, float x = 0f, float y = 0f)
        {
            TryBlendImageInternal(img: img, x: x, y: y);
        }
 public static bool TryBlendImage(this SciterGraphics graphics, SciterImage img, float x = 0f, float y = 0f)
 {
     return(graphics?.TryBlendImageInternal(img: img, x: x, y: y) == true);
 }
 public static SciterGraphics BlendImage(this SciterGraphics graphics, SciterImage img, float x = 0f, float y = 0f)
 {
     graphics?.BlendImageInternal(img: img, x: x, y: y);
     return(graphics);
 }