Ejemplo n.º 1
0
        // Get an image with specified dimension and pixel format
        public Bitmap GetImage(object sender, String text, Size size, PixelFormat format)
        {
            ArrayList names  = new ArrayList();
            ArrayList images = new ArrayList();

            foreach (ImageHandlerForm item in IHFList)
            {
                if ((item != sender) && (item is ImageHandlerForm))
                {
                    Bitmap img = (Bitmap)item.Image;
                    // check pixel format, width and height
                    if ((img.PixelFormat == format) &&
                        ((size.Width == -1) ||
                         ((img.Width == size.Width) && (img.Height == size.Height))))
                    {
                        names.Add(item.Text);
                        images.Add(img);
                    }
                }
            }

            SelectImageForm SIF = new SelectImageForm();

            SIF.Description = text;
            SIF.ImageNames  = names;
            // allow user to select an image
            if ((SIF.ShowDialog() == DialogResult.OK) && (SIF.SelectedItem != -1))
            {
                return((Bitmap)images[SIF.SelectedItem]);
            }
            return(null);
        }
Ejemplo n.º 2
0
        // Get an image with specified dimension and pixel format
        public Bitmap GetImage(object sender, String text, Size size, PixelFormat format)
        {
            ArrayList names = new ArrayList();
            ArrayList images = new ArrayList();
            foreach (ImageHandlerForm item in IHFList)
            {
                if ((item != sender) && (item is ImageHandlerForm))
                {
                    Bitmap img =(Bitmap) item.Image;
                    // check pixel format, width and height
                    if ((img.PixelFormat == format) &&
                        ((size.Width == -1) ||
                        ((img.Width == size.Width) && (img.Height == size.Height))))
                    {
                        names.Add(item.Text);
                        images.Add(img);
                    }
                }
            }

            SelectImageForm SIF = new SelectImageForm();
            SIF.Description = text;
            SIF.ImageNames = names;
            // allow user to select an image
            if ((SIF.ShowDialog() == DialogResult.OK) && (SIF.SelectedItem != -1))
            {
                return (Bitmap)images[SIF.SelectedItem];
            }
            return null;
        }