Esempio n. 1
0
        public override string AddImage(Image img)
        {
            if (img == null)
            {
                throw new ArgumentNullException("img");
            }

            var fullPath = "Pictures/" + img.DocumentFileName;
            using (var outStream = this.GetEntryOutputStream(fullPath))
            {
                outStream.Write(img.GetData(), 0, img.DataSize);
            }

            var manifestDoc = new OdfManifestDocument();
            using (var manifestInStream = this.GetEntryInputStream(OdfTemplate.ManifestEntryPath))
            {
                manifestDoc.Load(manifestInStream);
            }

            manifestDoc.AppendImageFileEntry(img.ExtensionName, fullPath);
            manifestDoc.CreatePicturesEntryElement();

            using (var manifestOutStream = this.GetEntryOutputStream(OdfTemplate.ManifestEntryPath))
            {
                manifestDoc.Save(manifestOutStream);
            }

            return fullPath;
        }
        private unsafe void calculateLinearMapForNeighbour(Image<Gray, byte> responseMap, int neigbourRow, int neighbourCol,
            Image<Gray, byte> linearMap)
        {
            Debug.Assert(linearMap.Width == linearMap.Stride); //because linear map should be represented as continous vector

            int neigborhood = this.NeigborhoodSize;

            byte* linMapPtr = (byte*)linearMap.ImageData;
            int linMapStride = linearMap.Stride;

            int width = responseMap.Width;
            int height = responseMap.Height;
            int stride = responseMap.Stride;
            byte* responseMapPtr = (byte*)responseMap.GetData(neigbourRow);

            //Two loops copy every T-th pixel into the linear memory
            for (int r = neigbourRow; r < height; r += neigborhood)
            {
                int linMapIdx = 0;
                for (int c = neighbourCol; c < width; c += neigborhood)
                {
                    linMapPtr[linMapIdx] = responseMapPtr[c];
                    linMapIdx++;
                }

                responseMapPtr += stride * neigborhood; //skip neigborhood rows
                linMapPtr += linMapStride;
            }
        }
Esempio n. 3
0
 public void TestConstructor()
 {
     var img1 = new Image(ImagePath);
     Assert.AreEqual("png", img1.ExtensionName);
     Assert.AreEqual(File.ReadAllBytes(ImagePath), img1.GetData());
 }