/// <summary> /// Resizes the specified bitmap. /// </summary> /// <param name="bitmap">The bitmap.</param> /// <param name="width">The width.</param> /// <param name="height">The height.</param> /// <param name="format">The format.</param> /// <returns></returns> public static byte[] Resize(this byte[] bitmap, int width, int height, ImageFormat format) { var converter = new Converter(); byte[] rotatedBits; using (Bitmap image = ConvertByteArrayToBitmap(bitmap)) { var i = Resize(image, width, height); rotatedBits = converter.ConvertBitmaptoBytes(i, format); } return rotatedBits; }
/// <summary> /// Resizes the specified bitmap. /// </summary> /// <param name="bitmap">The bitmap.</param> /// <param name="max"> The max height and the max width. </param> /// <param name="format">The format.</param> /// <returns></returns> public static byte[] ResizeToMax(this byte[] bitmap, Size max, ImageFormat format) { var converter = new Converter(); byte[] rotatedBits; using (Bitmap image = ConvertByteArrayToBitmap(bitmap)) { var size = ResizeToMaxWidthOrMaxHeight(image.Size, max); var resize = Resize(image, size.Width, size.Height); rotatedBits = converter.ConvertBitmaptoBytes(resize, format); } return rotatedBits; }
/// <summary> /// Rotates the specified b. /// </summary> /// <param name="b">The b.</param> /// <param name="angle">The angle.</param> /// <param name="format">The format.</param> /// <returns></returns> public static byte[] Rotate(this byte[] b, float angle, ImageFormat format) { var converter = new Converter(); byte[] rotatedImage; using (Bitmap image = b.ConvertByteArrayToBitmap()) { var i = Rotate(image, angle); rotatedImage = converter.ConvertBitmaptoBytes(i, format); } return rotatedImage; }
/// <summary> /// Rotate90s the degrees. /// </summary> /// <param name="bytes">The bytes.</param> /// <param name="flipType">Type of the flip.</param> /// <returns></returns> private static byte[] Rotate90Degrees(byte[] bytes, RotateFlipType flipType) { var converter = new Converter(); byte[] bitmaptoBytes; using (Bitmap bitmap = ConvertByteArrayToBitmap(bytes)) { bitmap.RotateFlip(flipType); bitmaptoBytes = converter.ConvertBitmaptoBytes(bitmap, ImageFormat.Jpeg); } return bitmaptoBytes; }
/// <summary> /// Converts the byte array to bitmap. /// </summary> /// <param name="bytes">The bytes.</param> /// <returns></returns> public static Bitmap ConvertByteArrayToBitmap(this byte[] bytes) { var converter = new Converter(); Bitmap image = converter.ConvertByteArrayToBitmap(bytes); return image; }