Пример #1
0
        public Present Evaluate(Present[] paramList)
        {
            D.Assert(paramList.Length == 3);
            for (int i = 0; i < paramList.Length; i++)
            {
                Present present = paramList[i];
                if (present is PresentFailureCode)
                {
                    return(present);
                }
            }
            if (!(paramList[0] is ImageRef))
            {
                return(paramList[0]);
            }
            ImageRef          imageRef          = (ImageRef)paramList[0];
            TileAddress       tileAddress       = (TileAddress)paramList[1];
            BoundsPresent     boundsPresent     = (BoundsPresent)paramList[2];
            MapRectangle      mapWindow         = CoordinateSystemUtilities.TileAddressToMapRectangle(this.coordinateSystem, tileAddress);
            Region            clipRegion        = boundsPresent.GetRenderRegion().GetClipRegion(mapWindow, tileAddress.ZoomLevel, this.coordinateSystem);
            GDIBigLockedImage gDIBigLockedImage = new GDIBigLockedImage(imageRef.image.Size, "UserClipperVerb");

            gDIBigLockedImage.SetClip(clipRegion);
            gDIBigLockedImage.DrawImageOntoThis(imageRef.image, new RectangleF(0f, 0f, (float)gDIBigLockedImage.Size.Width, (float)gDIBigLockedImage.Size.Height), new RectangleF(0f, 0f, (float)imageRef.image.Size.Width, (float)imageRef.image.Size.Height));
            ImageRef result = new ImageRef(new ImageRefCounted(gDIBigLockedImage));

            boundsPresent.Dispose();
            imageRef.Dispose();
            return(result);
        }
Пример #2
0
        public Present Evaluate(Present[] paramList)
        {
            D.Assert(paramList.Length == 2);
            MapRectangle value        = ((MapRectangleParameter)paramList[0]).value;
            Size         value2       = ((SizeParameter)paramList[1]).value;
            MapRectangle mapRectangle = value.Transform(imageTransformer.getDestLatLonToSourceTransformer())
                                        .GrowFraction(0.05);
            Present present = warpedBoundsFuture.Realize("WarpImageVerb.Evaluate-bounds");

            if (present is BoundsPresent)
            {
                MapRectangle boundingBox = ((BoundsPresent)present).GetRenderRegion().GetBoundingBox();
                if (!boundingBox.intersects(value))
                {
                    return(new BeyondImageBounds());
                }
            }

            Present present2 = sourceMapSupplier.Curry(new ParamDict(new object[]
            {
                TermName.ImageBounds, new MapRectangleParameter(mapRectangle)
            })).Realize("WarpImageVerb.Evaluate");

            if (present2 is PresentFailureCode)
            {
                return(present2);
            }

            ImageRef          imageRef          = (ImageRef)present2;
            GDIBigLockedImage gDIBigLockedImage = new GDIBigLockedImage(value2, "WarpImageVerb");

            imageTransformer.doTransformImage(imageRef.image, mapRectangle, gDIBigLockedImage, value);
            imageRef.Dispose();
            return(new ImageRef(new ImageRefCounted(gDIBigLockedImage)));
        }
Пример #3
0
        private unsafe Present FadeTile(ImageRef sourceImage, double fadeFactor)
        {
            GDIBigLockedImage image = new GDIBigLockedImage(sourceImage.image.Size, "FadeVerb");

            lock (sourceImage.image)
            {
                Image image2 = sourceImage.image.IPromiseIAmHoldingGDISLockSoPleaseGiveMeTheImage();
                lock (image)
                {
                    Image      image3     = image.IPromiseIAmHoldingGDISLockSoPleaseGiveMeTheImage();
                    Bitmap     bitmap     = (Bitmap)image2;
                    Bitmap     bitmap2    = (Bitmap)image3;
                    BitmapData bitmapdata = bitmap2.LockBits(new Rectangle(0, 0, bitmap2.Width, bitmap2.Height),
                                                             ImageLockMode.WriteOnly,
                                                             PixelFormat.Format32bppArgb);
                    BitmapData data2 = bitmap.LockBits(new Rectangle(0, 0, bitmap.Width, bitmap.Height),
                                                       ImageLockMode.ReadOnly,
                                                       PixelFormat.Format32bppArgb);
                    PixelStruct *structPtr  = (PixelStruct *)bitmapdata.Scan0;
                    PixelStruct *structPtr3 = (PixelStruct *)data2.Scan0;
                    int          width      = bitmapdata.Width;
                    int          height     = bitmapdata.Height;
                    int          num3       = bitmapdata.Stride / sizeof(PixelStruct);
                    for (int i = 0; i < height; i++)
                    {
                        int num4 = 0;
                        for (PixelStruct *structPtr2 = structPtr + i * num3; num4 < width; structPtr2++)
                        {
                            PixelStruct *structPtr4 = structPtr3 + i * num3 + num4;
                            structPtr2[0] = structPtr4[0];
                            structPtr2->a = (byte)(structPtr2->a * fadeFactor);
                            num4++;
                        }
                    }

                    bitmap2.UnlockBits(bitmapdata);
                    bitmap.UnlockBits(data2);
                }
            }

            sourceImage.Dispose();
            return(new ImageRef(new ImageRefCounted(image)));
        }
Пример #4
0
        public static void HaloTransparency(ImageRef source, int haloSize)
        {
            D.Assert(haloSize > 0 && haloSize < 100);
            ImageRef          imageRef = source.Copy();
            GDIBigLockedImage image;

            Monitor.Enter(image = source.image);
            try
            {
                Image image2 = source.image.IPromiseIAmHoldingGDISLockSoPleaseGiveMeTheImage();
                for (int i = -haloSize; i < haloSize + 1; i++)
                {
                    for (int j = -haloSize; j < haloSize + 1; j++)
                    {
                        if (i != 0 || j != 0)
                        {
                            Bitmap    bitmap   = new Bitmap(source.image.Width, source.image.Height);
                            Graphics  graphics = Graphics.FromImage(bitmap);
                            Rectangle destRect = new Rectangle(0, 0, image2.Width, image2.Height);
                            Rectangle srcRect  = new Rectangle(i, j, image2.Width, image2.Height);
                            graphics.DrawImage(image2, destRect, srcRect, GraphicsUnit.Pixel);
                            graphics.Dispose();
                            ImageRef imageRef2 = new ImageRef(new ImageRefCounted(new GDIBigLockedImage(bitmap)));
                            MaxInPlace(imageRef, imageRef2);
                            imageRef2.Dispose();
                        }
                    }
                }

                ReplaceAlphaChannel(source, imageRef);
            }
            finally
            {
                Monitor.Exit(image);
            }

            imageRef.Dispose();
        }
Пример #5
0
		private unsafe Present FadeTile(ImageRef sourceImage, double fadeFactor)
		{
            GDIBigLockedImage image = new GDIBigLockedImage(sourceImage.image.Size, "FadeVerb");
            lock (sourceImage.image)
            {
                Image image2 = sourceImage.image.IPromiseIAmHoldingGDISLockSoPleaseGiveMeTheImage();
                lock (image)
                {
                    Image image3 = image.IPromiseIAmHoldingGDISLockSoPleaseGiveMeTheImage();
                    Bitmap bitmap = (Bitmap)image2;
                    Bitmap bitmap2 = (Bitmap)image3;
                    BitmapData bitmapdata = bitmap2.LockBits(new Rectangle(0, 0, bitmap2.Width, bitmap2.Height), ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb);
                    BitmapData data2 = bitmap.LockBits(new Rectangle(0, 0, bitmap.Width, bitmap.Height), ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb);
                    PixelStruct* structPtr = (PixelStruct*)bitmapdata.Scan0;
                    PixelStruct* structPtr3 = (PixelStruct*)data2.Scan0;
                    int width = bitmapdata.Width;
                    int height = bitmapdata.Height;
                    int num3 = bitmapdata.Stride / sizeof(PixelStruct);
                    for (int i = 0; i < height; i++)
                    {
                        int num4 = 0;
                        for (PixelStruct* structPtr2 = structPtr + (i * num3); num4 < width; structPtr2++)
                        {
                            PixelStruct* structPtr4 = (structPtr3 + (i * num3)) + num4;
                            structPtr2[0] = structPtr4[0];
                            structPtr2->a = (byte)(structPtr2->a * fadeFactor);
                            num4++;
                        }
                    }
                    bitmap2.UnlockBits(bitmapdata);
                    bitmap.UnlockBits(data2);
                }
            }
            sourceImage.Dispose();
            return new ImageRef(new ImageRefCounted(image));
		}
Пример #6
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 (this.outputTileType == OutputTileType.IPIC)
					{
						if (transparentness == GDIBigLockedImage.Transparentness.EntirelyOpaque)
						{
							this.outputTileType = OutputTileType.JPG;
						}
						else
						{
							this.outputTileType = OutputTileType.PNG;
						}
					}
					RenderOutputUtil.SaveImage(imageRef, this.renderOutput, this.outputFilename, this.outputTileType.imageFormat);
				}
				this.feedback.PostImageResult(imageRef, this.layer, "(composite)", this.address);
				imageRef.Dispose();
			}
			catch (Exception arg)
			{
				this.feedback.PostMessage(string.Format("Can't create {0}: {1}", this.outputFilename, arg));
			}
		}
Пример #7
0
		public static void HaloTransparency(ImageRef source, int haloSize)
		{
			D.Assert(haloSize > 0 && haloSize < 100);
			ImageRef imageRef = source.Copy();
			GDIBigLockedImage image;
			Monitor.Enter(image = source.image);
			try
			{
				Image image2 = source.image.IPromiseIAmHoldingGDISLockSoPleaseGiveMeTheImage();
				for (int i = -haloSize; i < haloSize + 1; i++)
				{
					for (int j = -haloSize; j < haloSize + 1; j++)
					{
						if (i != 0 || j != 0)
						{
							Bitmap bitmap = new Bitmap(source.image.Width, source.image.Height);
							Graphics graphics = Graphics.FromImage(bitmap);
							Rectangle destRect = new Rectangle(0, 0, image2.Width, image2.Height);
							Rectangle srcRect = new Rectangle(i, j, image2.Width, image2.Height);
							graphics.DrawImage(image2, destRect, srcRect, GraphicsUnit.Pixel);
							graphics.Dispose();
							ImageRef imageRef2 = new ImageRef(new ImageRefCounted(new GDIBigLockedImage(bitmap)));
							TransparencyFuture.MaxInPlace(imageRef, imageRef2);
							imageRef2.Dispose();
						}
					}
				}
				TransparencyFuture.ReplaceAlphaChannel(source, imageRef);
			}
			finally
			{
				Monitor.Exit(image);
			}
			imageRef.Dispose();
		}
Пример #8
0
        private unsafe Present Evaluate(params Present[] paramList)
        {
            D.Assert(paramList.Length == 2);
            if (!(paramList[0] is ImageRef))
            {
                return(paramList[0]);
            }
            if (!(paramList[1] is ImageRef))
            {
                return(paramList[1]);
            }
            ImageRef          ref2  = (ImageRef)paramList[0];
            ImageRef          ref3  = (ImageRef)paramList[1];
            GDIBigLockedImage image = new GDIBigLockedImage(ref2.image.Size, "TransparencyFuture");

            lock (ref2.image)
            {
                Image image2 = ref2.image.IPromiseIAmHoldingGDISLockSoPleaseGiveMeTheImage();
                lock (ref3.image)
                {
                    Image image3 = ref3.image.IPromiseIAmHoldingGDISLockSoPleaseGiveMeTheImage();
                    lock (image)
                    {
                        BitmapData data3;
                        Image      image4     = image.IPromiseIAmHoldingGDISLockSoPleaseGiveMeTheImage();
                        Bitmap     bitmap     = (Bitmap)image2;
                        Bitmap     bitmap2    = (Bitmap)image4;
                        Bitmap     bitmap3    = (Bitmap)image3;
                        BitmapData bitmapdata = bitmap2.LockBits(new Rectangle(0, 0, bitmap2.Width, bitmap2.Height), ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb);
                        BitmapData data2      = bitmap.LockBits(new Rectangle(0, 0, bitmap.Width, bitmap.Height), ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb);
                        if (bitmap3 == bitmap)
                        {
                            data3 = data2;
                        }
                        else
                        {
                            data3 = bitmap3.LockBits(new Rectangle(0, 0, bitmap3.Width, bitmap3.Height), ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb);
                        }
                        PixelStruct *structPtr  = (PixelStruct *)bitmapdata.Scan0;
                        PixelStruct *structPtr3 = (PixelStruct *)data2.Scan0;
                        PixelStruct *structPtr5 = (PixelStruct *)data3.Scan0;
                        int          width      = bitmapdata.Width;
                        int          height     = bitmapdata.Height;
                        int          num3       = bitmapdata.Stride / sizeof(PixelStruct);
                        for (int i = 0; i < height; i++)
                        {
                            int num4 = 0;
                            for (PixelStruct *structPtr2 = structPtr + (i * num3); num4 < width; structPtr2++)
                            {
                                PixelStruct *structPtr4 = (structPtr3 + (i * num3)) + num4;
                                PixelStruct *structPtr6 = (structPtr5 + (i * num3)) + num4;
                                structPtr2[0] = structPtr4[0];
                                if (this.transparencyOptions.ShouldBeTransparent(structPtr6->r, structPtr6->g, structPtr6->b))
                                {
                                    structPtr2->a = 0;
                                }
                                num4++;
                            }
                        }
                        bitmap2.UnlockBits(bitmapdata);
                        bitmap.UnlockBits(data2);
                        if (bitmap3 != bitmap)
                        {
                            bitmap3.UnlockBits(data3);
                        }
                    }
                }
            }
            ref2.Dispose();
            ref3.Dispose();
            ImageRef source = new ImageRef(new ImageRefCounted(image));
            int      num6   = 0;

            foreach (TransparencyColor color in this.transparencyOptions.colorList)
            {
                num6 = Math.Max(num6, color.halo);
            }
            if (num6 > 0)
            {
                HaloTransparency(source, num6);
            }
            return(source);
        }