forked from DylanVann/react-native-fast-image
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBitmapSizeDecoder.java
More file actions
31 lines (24 loc) · 1.04 KB
/
BitmapSizeDecoder.java
File metadata and controls
31 lines (24 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package com.dylanvann.fastimage;
import android.graphics.BitmapFactory;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.bumptech.glide.load.Options;
import com.bumptech.glide.load.ResourceDecoder;
import com.bumptech.glide.load.engine.Resource;
import com.bumptech.glide.load.resource.SimpleResource;
import java.io.IOException;
import java.io.InputStream;
public class BitmapSizeDecoder implements ResourceDecoder<InputStream, BitmapFactory.Options> {
@Override
public boolean handles(@NonNull InputStream source, @NonNull Options options) throws IOException {
return true;
}
@Nullable
@Override
public Resource<BitmapFactory.Options> decode(@NonNull InputStream source, int width, int height, @NonNull Options options) throws IOException {
BitmapFactory.Options bitmapOptions = new BitmapFactory.Options();
bitmapOptions.inJustDecodeBounds = true;
BitmapFactory.decodeStream(source, null, bitmapOptions);
return new SimpleResource(bitmapOptions);
}
}