/// <summary> /// Adds a picture to the DB, generating color swatches beforehand /// </summary> /// <param name="picture"></param> /// <returns>Picture DTO object representing the object created in DB</returns> public async Task <PictureDTO> AddPicture(PictureDTO picture) { // Read the image from stream, convert it to Bitmap, and generate the swatches with it // in one using simply so that both the image and MemoryStream will dispose after being used using (var image = (Bitmap)Image.FromStream(new MemoryStream(picture.Contents))) picture.ColorSwatches = GenerateColorSwatches(image); var result = await _picturesRepository.AddAsync(picture); return(result); }