コード例 #1
0
        // Update parameters of a BMP image, and upload updated image to Cloud Storage.
        public void ModifyBmpAndUploadToStorage()
        {
            Console.WriteLine("Update parameters of a BMP image and upload to cloud storage");

            // Upload local image to Cloud Storage
            UploadSampleImageToCloud();

            int?   bitsPerPixel         = 32;
            int?   horizontalResolution = 300;
            int?   verticalResolution   = 300;
            bool?  fromScratch          = null;
            var    folder  = CloudPath; // Input file is saved at the Examples folder in the storage
            string storage = null;      // We are using default Cloud Storage

            var request = new ModifyBmpRequest(
                SampleImageFileName, bitsPerPixel, horizontalResolution, verticalResolution,
                fromScratch, folder, storage);

            Console.WriteLine(
                $"Call ModifyBmp with params: bits per pixel:{bitsPerPixel}, horizontal resolution:{horizontalResolution}, vertical resolution:{verticalResolution}");

            using (var updatedImage = ImagingApi.ModifyBmp(request))
            {
                // Upload updated image to Cloud Storage
                UploadImageToCloud(GetModifiedSampleImageFileName(), updatedImage);
            }

            Console.WriteLine();
        }
コード例 #2
0
        public void ModifyBmpTest()
        {
            string name                 = "test.bmp";
            int?   bitsPerPixel         = 32;
            int?   horizontalResolution = 300;
            int?   verticalResolution   = 300;
            bool?  fromScratch          = null;
            string folder               = TempFolder;
            string storage              = this.TestStorage;

            this.TestGetRequest(
                "ModifyBmpTest",
                $"Input image: {name}; Bits per pixel: {bitsPerPixel}; Horizontal resolution: {horizontalResolution}; Vertical resolution: {verticalResolution}",
                name,
                delegate
            {
                var request = new ModifyBmpRequest(name, bitsPerPixel, horizontalResolution, verticalResolution,
                                                   fromScratch, folder, storage);
                return(ImagingApi.ModifyBmp(request));
            },
                delegate(ImagingResponse originalProperties, ImagingResponse resultProperties, Stream resultStream)
            {
                Assert.IsNotNull(resultProperties.BmpProperties);
                Assert.AreEqual(bitsPerPixel, resultProperties.BitsPerPixel);
                Assert.AreEqual(verticalResolution, (int)Math.Ceiling((double)resultProperties.VerticalResolution));
                Assert.AreEqual(horizontalResolution, (int)Math.Ceiling((double)resultProperties.HorizontalResolution));

                Assert.IsNotNull(originalProperties.BmpProperties);
                Assert.AreEqual(originalProperties.BmpProperties.Compression,
                                resultProperties.BmpProperties.Compression);
                Assert.AreEqual(originalProperties.Width, resultProperties.Width);
                Assert.AreEqual(originalProperties.Height, resultProperties.Height);
            },
                folder,
                storage);
        }