コード例 #1
0
 public WatermarkRequest(WatermarkRequestFiles files, int opacity, WatermarkAlignment alignment, WatermarkOffset offset)
 {
     this.Files     = files;
     this.Opacity   = opacity;
     this.Alignment = alignment;
     this.Offset    = offset;
 }
コード例 #2
0
ファイル: WatermarkClient.cs プロジェクト: RSBlek/Corvida.API
        private async Task <Image> WatermarkRequest(WatermarkRequestFiles files, int opacity, WatermarkAlignment alignment = null, WatermarkOffset offset = null, WatermarkSize size = null)
        {
            if (!(opacity >= 0 && opacity <= 100))
            {
                throw new ArgumentException("Opacity is a percentage value and has to be between 0 and 100");
            }

            WatermarkRequest watermarkRequest = new WatermarkRequest(files, opacity, alignment, offset, size);
            HttpClient       httpClient       = HttpClientLazy.Value;


            String             json        = JsonSerializer.Serialize(watermarkRequest);
            StringContent      jsonContent = new StringContent(json, Encoding.UTF8, "application/json");
            HttpRequestMessage httpRequest = new HttpRequestMessage(HttpMethod.Post, this.Endpoint + "/watermark");

            httpRequest.Content = jsonContent;
            httpRequest.Headers.Add("Authorization", "ApiKey " + ApiKey.ToString());

            HttpResponseMessage response = await httpClient.SendAsync(httpRequest);

            await CheckSuccess(response);

            byte[] responseBytes = await response.Content.ReadAsByteArrayAsync();

            MemoryStream memoryStream = new MemoryStream(responseBytes);

            return(Image.FromStream(memoryStream));
        }
コード例 #3
0
ファイル: WatermarkClient.cs プロジェクト: RSBlek/Corvida.API
        public async Task <Image> WatermarkRequest(Image image, Image watermark, int opacity, WatermarkAlignment alignment = null, WatermarkOffset offset = null, WatermarkSize size = null)
        {
            WatermarkRequestFiles files = new WatermarkRequestFiles(ImageToBase64(image), ImageToBase64(watermark));

            return(await WatermarkRequest(files, opacity, alignment, offset, size));
        }