public BlobData GetDocImage(Guid docId, Guid attrDefId, int height = 0, int width = 0) { var imageData = DocRepo.GetBlobAttrData(docId, attrDefId); if (imageData == null) { return(null); } if (width <= 0 && height <= 0) { return(imageData); } using (var ms = new MemoryStream(imageData.Data)) { /*using (var img = Image.FromStream(ms)) * { * var fH = (double)((height > 0 && img.Height > height) ? height / img.Height : 1); * var fW = (double)((width > 0 && img.Width > width) ? width / img.Width : 1); * var factor = Math.Min(fH, fW); * var abort = new Image.GetThumbnailImageAbort(ThumbnailCallback); * using (var thumbnail = * img.GetThumbnailImage((int)(img.Width * factor), (int)(img.Height * factor), abort, * IntPtr.Zero)) * {*/ using (var ms2 = new MemoryStream()) { // thumbnail.Save(ms2, ImageFormat.Jpeg); ResizeImage(height, width, ms, ms2); ms2.Position = 0; return(new BlobData { Data = ms.ToArray(), FileName = imageData.FileName }); } /*} * }*/ } }
public BlobData GetDocBlob(Guid docId, Guid attrDefId) { var imageData = DocRepo.GetBlobAttrData(docId, attrDefId); return(imageData); }