Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Android - Bitmapは怖くない

Android - Bitmapは怖くない

Bitmapってどういうことが出来るか
・Picasso, GlideでのTransformationについて
・Frescoとは?
・GPUImage for Android

Daichi Furiya (Wasabeef)

April 25, 2015
Tweet

More Decks by Daichi Furiya (Wasabeef)

Other Decks in Programming

Transcript

  1. Supported Image Formats Format Encoder Decoder Details File Type JPEG

    ! ! Base+Progressive .jpg GIF ! .gif PNG ! ! .png BMP ! .bmp WebP !# 4.0+ !# 4.0+ .webp
  2. Glide • Picasso like • Video, Gif support • Sampling

    support • BitmapPool • Thumbnail change the world
  3. BitmapShader public static Bitmap shader(Bitmap src) { int width =

    src.getWidth(); int height = src.getHeight(); # bitmap = Bitmap.createBitmap(width, height, config); # Canvas canvas = new Canvas(bitmap); Paint paint = new Paint(); paint.setAntiAlias(true); BitmapShader shader = new BitmapShader( src, Shader.TileMode.CLAMP, Shader.TileMode.CLAMP); # paint.setShader(shader); RectF rectF = new RectF(margin, margin, width - margin, height - margin); canvas.drawRoundRect(recfF, radius, radius, paint); # return bitmap; }
  4. RenderScript ScriptIntrinsicBlur public static Bitmap blur(Bitmap src) { int width

    = src.getWidth(); int height = src.getHeight(); # bitmap = Bitmap.createBitmap(width, height, config); RenderScript rs = RenderScript.create(mContext); Allocation alloc = Allocation.createFromBitmap(rs, src); ScriptIntrinsicBlur blur = ScriptIntrinsicBlur.create(rs, alloc.getElement()); blur.setInput(alloc); blur.setRadius(mRadius); blur.forEach(alloc); alloc.copyTo(bitmap); source.recycle(); # return bitmap; }
  5. ColorFilter public static Bitmap color(Bitmap src, int color) { int

    width = src.getWidth(); int height = src.getHeight(); # bitmap = Bitmap.createBitmap(width, height, config); Canvas canvas = new Canvas(bitmap); Paint paint = new Paint(); paint.setAntiAlias(true); PorterDuffColorFilter filter = new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_ATOP); paint.setColorFilter(filter); canvas.drawBitmap(src, 0, 0, paint); # return bitmap; }
  6. GPUImage for Android @Override public void onCreate(final Bundle savedInstanceState) {

    super.onCreate(savedInstanceState); setContentView(R.layout.activity); # Uri imageUri = Uri.parse(“http://i.imgur.com/4rBHm4Q.jpg”); mGPUImage = new GPUImage(this); mGPUImage.setImage(imageUri); mGPUImage.setFilter(new GPUImageToonFilter()); # mGPUImage.saveToPictures(mGPUImage, “sample.jpg”, null); }
  7. Fresco <com.facebook.drawee.view.SimpleDraweeView android:id="@+id/my_image_view" android:layout_width="200dp" android:layout_height="200dp" fresco:fadeDuration="300" fresco:actualImageScaleType="focusCrop" fresco:placeholderImage="@color/wait_color" fresco:placeholderImageScaleType="fitCenter" fresco:failureImage="@drawable/error"

    fresco:failureImageScaleType="centerInside" fresco:retryImage="@drawable/retrying" fresco:retryImageScaleType="centerCrop" fresco:progressBarImage="@drawable/progress_bar" fresco:progressBarImageScaleType="centerInside" fresco:progressBarAutoRotateInterval="1000" fresco:backgroundImage="@color/blue" fresco:overlayImage="@drawable/watermark" fresco:pressedStateOverlayImage="@color/red" fresco:roundAsCircle="false" fresco:roundedCornerRadius="1dp" fresco:roundTopLeft="true" fresco:roundTopRight="false" fresco:roundBottomLeft="false" fresco:roundBottomRight="true" fresco:roundWithOverlayColor="@color/corner_color" fresco:roundingBorderWidth="2dp" fresco:roundingBorderColor=“@color/border_color"/>
  8. largeHeap == true? • Google+ • Amazon Kindle • Facebook

    • Hulu • Tumblr • Youtube • Ameba Ownd