public byte[] scaleStreamImageTo(int outWidth, int outHeight) { int x, y, w, h; int iWoH = mImage.Width * outHeight; int iHoW = mImage.Height * outWidth; if (iWoH < iHoW) { w = (int)((double)(iWoH) / mImage.Height); h = outHeight; x = (int)((outWidth - w) / 2.0); y = 0; } else { w = outWidth; h = (int)((double)(iHoW) / mImage.Width); x = 0; y = (int)((outHeight - h) / 2.0); } using (Bitmap outImage = new Bitmap(outWidth, outHeight)) { drawImage(mImage, outImage, new Rectangle(x, y, w, h)); return(ImageOps.imageToByteArray(outImage)); } }
public byte[] scaleStreamImageBy(float scaleFactor) { int outWidth = (int)(mImage.Width * scaleFactor); int outHeight = (int)(mImage.Height * scaleFactor); using (Bitmap outImage = new Bitmap(outWidth, outHeight)) { drawImage(mImage, outImage, new Rectangle(0, 0, outWidth, outHeight)); return(ImageOps.imageToByteArray(outImage)); } }
public override IEnumerable <IRow> Extract(IUnstructuredReader input, IUpdatableRow output) { byte[] img = ImageOps.GetByteArrayforImage(input.BaseStream); // load image only once into memory per row using (StreamImage inImage = new StreamImage(img)) { output.SetColumnIfExists("image", img); output.SetColumnIfExists("equipment_make", inImage.getStreamImageProperty(ImageProperties.equipment_make)); output.SetColumnIfExists("equipment_model", inImage.getStreamImageProperty(ImageProperties.equipment_model)); output.SetColumnIfExists("description", inImage.getStreamImageProperty(ImageProperties.description)); output.SetColumnIfExists("copyright", inImage.getStreamImageProperty(ImageProperties.copyright)); output.SetColumnIfExists("thumbnail", inImage.scaleStreamImageTo(this._scaleWidth, this._scaleHeight)); } yield return(output.AsReadOnly()); }
public override IEnumerable <IRow> Extract(IUnstructuredReader input, IUpdatableRow output) { byte[] imageArray = ImageOps.GetByteArrayforImage(input.BaseStream); output.Set <byte[]>(0, imageArray); yield return(output.AsReadOnly()); }