Ejemplo n.º 1
0
        public override bool DoWork(ITileWorkFeedback feedback)
        {
            this.feedback = feedback;
            bool result;

            try
            {
                D.Sayf(0, "{0} start compositing {1}", new object[]
                {
                    Clocker.theClock.stamp(),
                    this
                });
                if (!this.NeedThisTile())
                {
                    D.Say(10, "Skipping extant file: " + this.outputFilename);
                    result = false;
                }
                else
                {
                    D.Sayf(10, "Compositing {0}", new object[]
                    {
                        this.address
                    });
                    Size tileSize = new MercatorCoordinateSystem().GetTileSize();
                    GDIBigLockedImage gDIBigLockedImage = new GDIBigLockedImage(tileSize, "CompositeTileUnit");
                    D.Say(10, string.Format("Start({0}) sm.count={1}", this.address, this.singleSourceUnits.Count));
                    foreach (SingleSourceUnit current in this.singleSourceUnits)
                    {
                        current.CompositeImageInto(gDIBigLockedImage);
                    }
                    this.SaveTile(gDIBigLockedImage);
                    result = true;
                }
            }
            catch (NonredundantRenderComplaint complaint)
            {
                feedback.PostComplaint(complaint);
                result = false;
            }
            catch (Exception arg)
            {
                feedback.PostMessage(string.Format("Exception compositing tile {0}: {1}", this.address, arg));
                result = false;
            }
            return(result);
        }
Ejemplo n.º 2
0
		public override bool DoWork(ITileWorkFeedback feedback)
		{
			this.feedback = feedback;
			bool result;
			try
			{
				D.Sayf(0, "{0} start compositing {1}", new object[]
				{
					Clocker.theClock.stamp(),
					this
				});
				if (!this.NeedThisTile())
				{
					D.Say(10, "Skipping extant file: " + this.outputFilename);
					result = false;
				}
				else
				{
					D.Sayf(10, "Compositing {0}", new object[]
					{
						this.address
					});
					Size tileSize = new MercatorCoordinateSystem().GetTileSize();
					GDIBigLockedImage gDIBigLockedImage = new GDIBigLockedImage(tileSize, "CompositeTileUnit");
					D.Say(10, string.Format("Start({0}) sm.count={1}", this.address, this.singleSourceUnits.Count));
					foreach (SingleSourceUnit current in this.singleSourceUnits)
					{
						current.CompositeImageInto(gDIBigLockedImage);
					}
					this.SaveTile(gDIBigLockedImage);
					result = true;
				}
			}
			catch (NonredundantRenderComplaint complaint)
			{
				feedback.PostComplaint(complaint);
				result = false;
			}
			catch (Exception arg)
			{
				feedback.PostMessage(string.Format("Exception compositing tile {0}: {1}", this.address, arg));
				result = false;
			}
			return result;
		}
Ejemplo n.º 3
0
        private void SaveTile(GDIBigLockedImage compositeImage)
        {
            try
            {
                ImageRef imageRef = new ImageRef(new ImageRefCounted(compositeImage));
                GDIBigLockedImage.Transparentness transparentness = imageRef.image.GetTransparentness();
                if (transparentness == GDIBigLockedImage.Transparentness.EntirelyTransparent)
                {
                    D.Sayf(0, "skipping blank tile.", new object[0]);
                }
                else
                {
                    if (outputTileType == OutputTileType.IPIC)
                    {
                        if (transparentness == GDIBigLockedImage.Transparentness.EntirelyOpaque)
                        {
                            outputTileType = OutputTileType.JPG;
                        }
                        else
                        {
                            outputTileType = OutputTileType.PNG;
                        }
                    }

                    RenderOutputUtil.SaveImage(imageRef,
                                               renderOutput,
                                               outputFilename,
                                               outputTileType.imageFormat);
                }

                feedback.PostImageResult(imageRef, layer, "(composite)", address);
                imageRef.Dispose();
            }
            catch (Exception arg)
            {
                feedback.PostMessage(string.Format("Can't create {0}: {1}", outputFilename, arg));
            }
        }