Пример #1
0
        private void CreateReferenceImage(string name, int width, int height, Action <Canvas> renderMethod)
        {
            PixelData image = this.RenderToTexture(width, height, renderMethod);

            string      formatId = ImageCodec.FormatPng;
            IImageCodec codec    = ImageCodec.GetWrite(formatId);

            using (Stream stream = File.Open(TestHelper.GetEmbeddedResourcePath(name, ".png"), FileMode.Create))
            {
                codec.Write(stream, image, formatId);
            }
        }
Пример #2
0
        void ISerializeExplicit.WriteData(IDataWriter writer)
        {
            string formatId = ImageCodec.FormatPng;

            writer.WriteValue("version", Serialize_Version_FormatId);
            writer.WriteValue("formatId", formatId);

            IImageCodec codec = ImageCodec.GetWrite(formatId);

            if (codec == null)
            {
                throw new NotSupportedException(string.Format(
                                                    "Unable to retrieve image codec for format '{0}'. Can't save image data.",
                                                    formatId));
            }

            using (MemoryStream str = new MemoryStream(1024 * 64))
            {
                codec.Write(str, this, formatId);
                writer.WriteValue("pixelData", str.ToArray());
            }
        }