1

In ArcMap in symbol-dialog you can choose a predefined symbol for your polygon-features, i.e. agricultural area. This is a 1 bit picture with foreground- and background color. I grab this symbol as IPictureFillSymbol. It has a member picture, which is a stdole.IPictureDisp. Has anyone an idea how to access the fill pattern perhaps as hexcode or sth. else? In ArcView it was called stipple.

I'm in the dark.

  • 1
    Have you seen this article? blogs.msdn.microsoft.com/andreww/2007/07/30/… – Kirk Kuykendall Mar 23 '16 at 15:04
  • Thanks for that, I use the VB6 compatibility library to convert the IPictureDisp to an System.Drawing.Image/ Bitmap. That works good and is simple. Just what I needed. Then I will go through the pixels and read the stipple. When its done I will post the code, maybe someone is interested in. – Ms. Smith Mar 24 '16 at 9:28
1

With the hint from Kirk Kuykendall I could transform the IPictureDisp to a System.Drawing.Image with the function VB6CompatibilityConverter.PictureDispToImage. Then I read the BMP pixelwise into a bitfield and finally transform it into a hexcode (using the function BinaryStringToHexString)

Why do this? Now the stipple could be transformed back into a picture using it in another gis or in arcmap too.

private static string GetFillStipple(IPictureFillSymbol iSymbol)
    {
        try
        {
            stdole.IPictureDisp pd = (iSymbol as IPictureFillSymbol).Picture;
            System.Drawing.Image img = VB6CompatibilityConverter.PictureDispToImage(pd);
            System.Drawing.Bitmap bmp = img as System.Drawing.Bitmap;

            if (img.PixelFormat != System.Drawing.Imaging.PixelFormat.Format1bppIndexed) return "";

            // go through the canvas and read the pixels into a bit-field
            string bits = "";
            for (int i = 0; i < bmp.Height; i++)
            {
                for (int j = 0; j < bmp.Width; j++)
                {
                    System.Drawing.Color col = bmp.GetPixel(j, i);
                    bits += (col == bmp.Palette.Entries[0]) ? "1" : "0";
                }
            }

            // transfer it to a hex-code
           return string.Join(",", new string[] { BinaryStringToHexString(bits), bmp.Width.ToString(), bmp.Height.ToString() });

        }
        catch (Exception ex)
        {
            return "";
        }
    }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.