Example #1
0
 public SharedImage(MemoryImage image, int CRC = 0)
 {
     // CRC can be provided if already calculated - to avoid recalculating it
     m_Image = image;
     if (CRC == 0)
     {
         CRC = image.CalcCRC();
     }
     this.CRC = CRC;
 }
Example #2
0
        public override void CopyFrom(Datum other, CopyDepth depth, Mapping mapID)
        {
            base.CopyFrom(other, depth, mapID);
            SharedImage sharedImage = (SharedImage)other;

            if (depth >= CopyDepth.Duplicate)
            {
                m_Image = sharedImage.m_Image?.Clone();
                CRC     = sharedImage.CRC;
            }
            m_ResourceName = sharedImage.m_ResourceName;
        }
Example #3
0
 public void WriteOptionalMemoryImage(MemoryImage image)
 {
     if (image == null)
     {
         Write(false);
     }
     else
     {
         Write(true);
         image.Save(this);
     }
 }
Example #4
0
File: SVG.cs Project: stuart2w/SAW
        public override void DrawImage(MemoryImage image, RectangleF destination, RectangleF sourceRect, System.Drawing.Imaging.ImageAttributes attributes = null)
        {
            if (image.IsSVG && sourceRect.Location.IsEmpty && sourceRect.Size.Equals(image.Size.ToSizeF()))
            {             // sourceRect param was actually redundant as it specifies the entire thing
                          // this check done for efficiency, since if rendering the entire thing we can use SVG, whereas code below generates an entire new image each time
                DrawImage(image, destination, attributes);
                return;
            }
            string ID = PrepareMemoryImage(image, image.GetHashCode(), sourceRect);

            SimpleImage(ID, sourceRect.Size, destination);
        }
Example #5
0
 public override void Load(DataReader reader)
 {
     base.Load(reader);
     CRC = reader.ReadInt32();
     if (reader.Version < 76 || reader.ReadBoolean())             // Version 76 onwards start with a boolean indicating what is stored in the object
     {
         m_Image = new MemoryImage(reader);
     }
     else
     {
         m_ResourceName = reader.ReadString();
     }
 }
Example #6
0
        /// <summary>Adds the given file to the displayed list</summary>
        private void ShowPicture(DisplayedImage image)
        {
            PictureBox  ctr    = new PictureBox();
            MemoryImage memory = new MemoryImage(image.Filename);             // this is used for its SVG handling.  We don't really need the memory buffer overhead!

            ctr.Image        = memory.GetNetImage();
            ctr.Tag          = image;
            ctr.Size         = new Size(100, 100);
            ctr.SizeMode     = PictureBoxSizeMode.Zoom;
            ctr.Margin       = new Padding(10, 10, 10, 10);
            ctr.Padding      = new Padding(10, 10, 10, 10);
            ctr.Click       += Image_Click;
            ctr.DoubleClick += Image_DoubleClick;
            pnlImages.Controls.Add(ctr);
        }
Example #7
0
        public void btnChangeActivityIcon_Click(object sender, EventArgs e)
        {
            string filename = FileDialog.ShowOpen(FileDialog.Context.Image);

            if (string.IsNullOrEmpty(filename))
            {
                return;
            }
            m_Image = new MemoryImage(filename);
            m_Image.ChangeToBitmap(new Size(144, 144));
            pnlPreviewActivityIcon.Image = m_Image.GetNetImage();
            EnableOK();
            Globals.OnAvailableActivitiesChanged();
            // We should also raise this if the text changes; but that's more complicated if we don't want to raise numerous events, and I'm not sure it's worth the effort
        }
Example #8
0
File: SVG.cs Project: stuart2w/SAW
        private string PrepareMemoryImage(MemoryImage img, int imageKey, RectangleF source)
        {
            if (!img.IsSVG)
            {
                return(PrepareImage((Bitmap)img.GetNetImage(true), imageKey, source));
            }

            // rest for SVG only, which partially repeats PrepareImage (above)
            string     ID     = "img" + imageKey.ToString("x");
            RectangleF bounds = new RectangleF(PointF.Empty, img.Size);

            if (!source.IsEmpty && !source.Equals(bounds))
            {
                ID += "_" + source.GetHashCode();
            }
            if (!m_Images.Contains(ID))
            {             // for SVG images can just retrieve the data directly from the memory image (no need to worry about formats)
                Debug.Assert(img.Buffer != null);
                AddImageToDefinitions(img.Buffer, ID, img.Size, "svg+xml");
            }
            return(ID);
        }
Example #9
0
 public abstract void DrawImage(MemoryImage image, PointF[] destinationPoints, RectangleF sourceRect, ImageAttributes attributes = null);
Example #10
0
 // The image can be specified in 3 ways.  cannot just use .net images because PDF/SVG can't really use these.  We need access to the underlying data
 // likewise there are 3 different ways of specifying the coordinates
 public abstract void DrawImage(MemoryImage image, RectangleF destination, ImageAttributes attributes = null);
Example #11
0
 public override void DrawImage(MemoryImage image, PointF[] destinationPoints, RectangleF sourceRect, ImageAttributes attributes = null)
 {
     image.Draw(gr, destinationPoints, sourceRect, attributes);
 }
Example #12
0
 public override void DrawImage(MemoryImage image, RectangleF destination, ImageAttributes attributes = null)
 {
     image.Draw(gr, destination, attributes);
 }
Example #13
0
File: SVG.cs Project: stuart2w/SAW
        public override void DrawImage(MemoryImage image, RectangleF destination, System.Drawing.Imaging.ImageAttributes attributes = null)
        {
            string ID = PrepareMemoryImage(image, image.GetHashCode(), RectangleF.Empty);

            SimpleImage(ID, image.Size, destination);
        }
Example #14
0
File: SVG.cs Project: stuart2w/SAW
        public override void DrawImage(MemoryImage image, PointF[] destinationPoints, RectangleF sourceRect, System.Drawing.Imaging.ImageAttributes attributes = null)
        {
            var ID = PrepareMemoryImage(image, image.GetHashCode(), sourceRect);

            ComplexImage(ID, sourceRect, destinationPoints);
        }