public void Effect(JMImageEffect effect, ImageFormat imageFormat, Action <byte[]> callback = null) { Bitmap bitmap = null; byte[] datas = null; try { if (_originBitmap != null) { using (bitmap = new Bitmap(_originBitmap.Width, _originBitmap.Height)) { ConvertBitmap(effect, _originBitmap, bitmap); datas = BitmapConvert.ToBuffer(bitmap, imageFormat); } } } catch { if (bitmap != null) { bitmap.Dispose(); } } if (callback != null) { callback.Invoke(datas); } }
public void Effect(JMImageEffect effect, string dstImagePath, ImageFormat imageFormat) { Bitmap bitmap = null; try { FileUtility.CreateDir(dstImagePath); if (_originBitmap != null) { using (bitmap = new Bitmap(_originBitmap.Width, _originBitmap.Height)) { ConvertBitmap(effect, _originBitmap, bitmap); bitmap.Save(dstImagePath, imageFormat); } } } catch { if (bitmap != null) { bitmap.Dispose(); } } }
public void Effect(JMImageEffect effect, ImageFormat imageFormat, Action <byte[]> callback = null) { byte[] datas = null; Bitmap bitmap = null; try { if (_colors != null) { using (bitmap = new Bitmap(_colors.GetLength(0), _colors.GetLength(1))) { ConvertColors(effect, _colors, bitmap); datas = BitmapConvert.ToBuffer(bitmap, imageFormat); } } } catch { if (bitmap != null) { bitmap.Dispose(); } } if (callback != null) { callback.Invoke(datas); } }
public void Effect(JMImageEffect effect, string dstImagePath, ImageFormat imageFormat) { if (_colors != null) { Bitmap bitmap = null; try { FileUtility.CreateDir(dstImagePath); using (bitmap = new Bitmap(_colors.GetLength(0), _colors.GetLength(1))) { ConvertColors(effect, _colors, bitmap); bitmap.Save(dstImagePath); } } catch { if (bitmap != null) { bitmap.Dispose(); } } } }
/// <summary> /// 转换Bitmap /// </summary> private void ConvertBitmap(JMImageEffect effect, Bitmap oldBitmap, Bitmap newBitmap) { switch (effect) { case JMImageEffect.Negative: NegativeEffectBitmap(oldBitmap, newBitmap); break; case JMImageEffect.Relief: ReliefEffectBitmap(oldBitmap, newBitmap); break; } }
/// <summary> /// 转换Colors /// </summary> private void ConvertColors(JMImageEffect effect, Color[,] colors, Bitmap newBitmap) { switch (effect) { case JMImageEffect.Negative: NegativeEffectColors(colors, newBitmap); break; case JMImageEffect.Relief: ReliefEffectColors(colors, newBitmap); break; } }