示例#1
0
        /// <summary>
        /// set local loaded image
        /// </summary>
        /// <param name="image"></param>
        public virtual void SetLocalImage(PixelFarm.Drawing.Image image, bool raiseEvent = true)
        {
            //set image to this binder
            if (image != null)
            {
                _localImg  = image;
                this.State = BinderState.Loaded;


                if (raiseEvent)
                {
                    RaiseImageChanged();
                }
                else
                {
                    //eg. when we setLocalImage
                    //from other thread
                    //don't call raise image changed directly here
                    //please use 'main thread queue' to invoke this
                }
            }
            else
            {
                //if set to null
            }
        }
 public void SetImage(PixelFarm.Drawing.Image image)
 {
     //set image to this binder
     if (image != null)
     {
         this._image = image;
         this.State  = ImageBinderState.Loaded;
         this.OnImageChanged();
     }
 }
示例#3
0
        public ImageBinder(PixelFarm.Drawing.Image otherImg, bool isMemBmpOwner = false)
        {
#if DEBUG
            if (otherImg == null)
            {
                throw new NotSupportedException();
            }
#endif
            //binder to image
            _localImg        = otherImg;
            _isLocalImgOwner = isMemBmpOwner; //if true=> this binder will release a local cahed img
            this.State       = BinderState.Loaded;
        }
示例#4
0
        public ImageBinder(PixelFarm.CpuBlit.MemBitmap memBmp, bool isMemBmpOwner = false)
        {
#if DEBUG
            if (memBmp == null)
            {
                throw new NotSupportedException();
            }
#endif
            //binder to image
            _localImg        = memBmp;
            _isLocalImgOwner = isMemBmpOwner; //if true=> this binder will release a local cahed img
            this.State       = BinderState.Loaded;
        }
示例#5
0
 /// <summary>
 /// On image load in renderer set the image by event async.
 /// </summary>
 void HandleImageRequest(object sender, ImageRequestEventArgs e)
 {
     PixelFarm.Drawing.Image img = TryLoadResourceImage(e.ImagSource);
     if (img != null)
     {
         e.SetResultImage(img);
     }
     else
     {
         //no image found
         e.ImageBinder.State = ImageBinderState.Error;
     }
 }
示例#6
0
        public void ClearLocalImage()
        {
            this.State = BinderState.Unloading;//reset this to unload?

            if (_localImg != null)
            {
                if (_isLocalImgOwner)
                {
                    _localImg.Dispose();
                }
                _localImg = null;
            }

            //TODO: review here
            this.State = BinderState.Unload;//reset this to unload?
        }
示例#7
0
        public static PixelFarm.DrawingGL.GLBitmap LoadTexture(PixelFarm.Drawing.Image bmp)
        {
            return(null);

            //var bmpdata = bmp.LockBits(new System.Drawing.Rectangle(0, 0, bmp.Width, bmp.Height),
            //    System.Drawing.Imaging.ImageLockMode.ReadOnly,
            //    System.Drawing.Imaging.PixelFormat.Format32bppArgb);
            //int stride = bmpdata.Stride;
            //byte[] buffer = new byte[stride * bmp.Height];
            //System.Runtime.InteropServices.Marshal.Copy(bmpdata.Scan0, buffer, 0, buffer.Length);
            //bmp.UnlockBits(bmpdata);
            ////---------------------------
            ////if we are on Little-endian  machine,
            ////
            ////---------------------------
            //return new PixelFarm.DrawingGL.GLBitmap(bmp.Width, bmp.Height, buffer, false);
        }
示例#8
0
 /// <summary>
 /// set local loaded image
 /// </summary>
 /// <param name="image"></param>
 public virtual void SetLocalImage(PixelFarm.Drawing.Image image, bool fromAnotherThread = false)
 {
     //set image to this binder
     if (image != null)
     {
         _localImg  = image;
         this.State = BinderState.Loaded;
         if (!fromAnotherThread)
         {
             this.RaiseImageChanged();
         }
         else
         {
             UIMsgQueue.RegisterRunOnce(() => this.RaiseImageChanged());
         }
     }
     else
     {
         //if set to null
     }
 }
示例#9
0
 public static void SetImage(PixelFarm.Drawing.Image img) => s_currentUIPlatform.SetClipboardImage(img);
示例#10
0
 void ImgBinderLoadImg(PixelFarm.Drawing.ImageBinder reqImgBinder, VgVisualElement vgVisualE, object o)
 {
     PixelFarm.Drawing.Image img = _host.LoadImage(reqImgBinder.ImageSource);
     reqImgBinder.SetLocalImage(img);
     reqImgBinder.State = PixelFarm.Drawing.BinderState.Loaded;
 }
示例#11
0
 public abstract void SetClipboardImage(PixelFarm.Drawing.Image img);