Esempio n. 1
0
        public Stream getMIA(string index, string session)
        {
            ImgRecord r       = sessions[session][int.Parse(index)];
            Stream    fstream = safeOpen("File" + r.file);
            Bitmap    image   = new Bitmap(fstream);

            int width  = image.Size.Width;
            int height = image.Size.Height;

            Rectangle MIARect = trimRect(miaFinder.mostInterestingArea(image), image);

            /*
             * String[] parts = imageFilePath.Split('-');
             * String index = parts[0];
             * String session = parts[1];
             */
            //  Bitmap image2 = ObjectCopier.Clone(image);
            //Rule of thirds
            Rectangle ROTRect = trimRect(rotFinder.mostInterestingArea(image), image);

            //Most colorful

            //   Bitmap image3 = ObjectCopier.Clone(image);
            Rectangle MCRect = trimRect(mcaFinder.mostInterestingArea(image), image);

            //Rectangle MCRect = new Rectangle(10, 50, 10, 100);
            fstream.Dispose();
            image.Dispose();
            String styleText = "" + MIARect.Top + ";" + MIARect.Left + ";" + MIARect.Width + ";" + MIARect.Height + ";" + ROTRect.Top + ";" + ROTRect.Left + ";" + ROTRect.Width + ";" + ROTRect.Height + ";" + +MCRect.Top + ";" + MCRect.Left + ";" + MCRect.Width + ";" + MCRect.Height
                               + ";" + width + ";" + height;

            return(new MemoryStream(Encoding.UTF8.GetBytes(styleText)));
        }
Esempio n. 2
0
        public void crop(string number, string session)
        {
            try
            {
                ImgRecord r     = sessions[session][int.Parse(number)];
                Bitmap    image = new Bitmap("File" + r.file);
                Rectangle rect  = new Rectangle(int.Parse(getParam("left")), int.Parse(getParam("top")), int.Parse(getParam("width")), int.Parse(getParam("height")));
                rect = trimRect(rect, image);

                Image x = image.Clone(rect, image.PixelFormat);
                image.Dispose();
                r.file = nextFile();
                x.Save("File" + r.file);
                //Saves as png, so fix things.
                r.type = "image/png";
                int ix = r.name.LastIndexOf('.');
                if (ix != -1)
                {
                    r.name = r.name.Substring(0, ix + 1) + "png";
                }
                x.Dispose();
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
            }
        }
Esempio n. 3
0
        public Stream fileGet(string number, string session)
        {
            ImgRecord r = sessions[session][int.Parse(number)];

            WebOperationContext.Current.OutgoingResponse.Headers.Add("Content-Disposition", "attachment; filename=\"" + r.name + "\"");
            WebOperationContext.Current.OutgoingResponse.ContentType = r.type;
            return(safeOpen("File" + r.file));
        }