Beispiel #1
0
        public static ImageAnnotation GetAnnotation(string library, Bitmap image, IBoundingBox region)
        {
            CouchDatabase   db    = GetDatabase(library);
            string          imgid = ImageAnnotation.GetImageId(image);
            ImageAnnotation ia    = new ImageAnnotation(region, null, imgid);

            try
            {
                CouchDbAnnotation ca = db.GetDocument <CouchDbAnnotation>(ia.Id);
                return(new ImageAnnotation(region, ca.data, imgid));
            }
            catch
            {
                return(null);
            }
        }
Beispiel #2
0
        private static string AddImage(CouchDatabase db, Bitmap image)
        {
            string imgid = ImageAnnotation.GetImageId(image);

            if (!HasDocument(db, imgid))
            {
                JObject imgJson = new JObject();
                imgJson["_id"]  = imgid;
                imgJson["type"] = "screenshot";
                Document doc = new Document(imgJson);
                db.CreateDocument(doc);
                System.Drawing.Bitmap bmp       = Bitmap.ToSystemDrawingBitmap(image);
                ImageConverter        converter = new ImageConverter();
                byte[] imgbytes = (byte[])converter.ConvertTo(bmp, typeof(byte[]));

                db.AddAttachment(imgid, imgbytes, "image", "image/png");
            }
            return(imgid);
        }