Пример #1
0
        public override bool Save(Stream stream, GMap.NET.PureImage image)
        {
            GMapImage ret = image as GMapImage;
            bool      ok  = true;

            if (ret.Img != null)
            {
                // try png
                try
                {
                    ret.Img.Save(stream, System.Drawing.Imaging.ImageFormat.Png);
                }
                catch
                {
                    // try jpeg
                    try
                    {
                        stream.Seek(0, SeekOrigin.Begin);
                        ret.Img.Save(stream, System.Drawing.Imaging.ImageFormat.Jpeg);
                    }
                    catch
                    {
                        ok = false;
                    }
                }
            }
            else
            {
                ok = false;
            }

            return(ok);
        }
Пример #2
0
        public override PureImage FromStream(Stream stream)
        {
            GMapImage ret = null;

            try
            {
#if !PocketPC
                Image m = Image.FromStream(stream, true, Win7OrLater ? false : true);
#else
                Image m = new Bitmap(stream);
#endif
                if (m != null)
                {
                    ret = new GMapImage();
#if !PocketPC
                    ret.Img = ColorMatrix != null?ApplyColorMatrix(m, ColorMatrix) : m;
#else
                    ret.Img = m;
#endif
                }
            }
            catch (Exception ex)
            {
                ret = null;
                Debug.WriteLine("FromStream: " + ex.ToString());
            }

            return(ret);
        }