Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
沉迷打码的小凳子
glide
提交
f0c8a95c
G
glide
项目概览
沉迷打码的小凳子
/
glide
与 Fork 源项目一致
从无法访问的项目Fork
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
glide
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
f0c8a95c
编写于
10月 22, 2014
作者:
S
Sam Judd
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Return null when gif frame cannot be decoded.
More work toward #212.
上级
f4e84300
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
46 addition
and
3 deletion
+46
-3
library/src/androidTest/java/com/bumptech/glide/load/resource/gif/GifFrameResourceDecoderTest.java
.../glide/load/resource/gif/GifFrameResourceDecoderTest.java
+8
-0
library/src/androidTest/java/com/bumptech/glide/load/resource/gif/GifResourceDecoderTest.java
...ptech/glide/load/resource/gif/GifResourceDecoderTest.java
+20
-1
library/src/main/java/com/bumptech/glide/load/resource/gif/GifFrameResourceDecoder.java
...tech/glide/load/resource/gif/GifFrameResourceDecoder.java
+5
-1
library/src/main/java/com/bumptech/glide/load/resource/gif/GifResourceDecoder.java
.../bumptech/glide/load/resource/gif/GifResourceDecoder.java
+4
-0
third_party/gif_decoder/src/main/java/com/bumptech/glide/gifdecoder/GifDecoder.java
...c/main/java/com/bumptech/glide/gifdecoder/GifDecoder.java
+9
-1
未找到文件。
library/src/androidTest/java/com/bumptech/glide/load/resource/gif/GifFrameResourceDecoderTest.java
浏览文件 @
f0c8a95c
...
...
@@ -12,6 +12,7 @@ import org.robolectric.RobolectricTestRunner;
import
java.io.IOException
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertNull
;
import
static
org
.
mockito
.
Mockito
.
mock
;
import
static
org
.
mockito
.
Mockito
.
when
;
...
...
@@ -38,4 +39,11 @@ public class GifFrameResourceDecoderTest {
assertEquals
(
expected
,
resourceDecoder
.
decode
(
gifDecoder
,
100
,
100
).
get
());
}
@Test
public
void
testReturnsNullIfGifDecoderReturnsNullFrame
()
{
when
(
gifDecoder
.
getNextFrame
()).
thenReturn
(
null
);
assertNull
(
resourceDecoder
.
decode
(
gifDecoder
,
100
,
100
));
}
}
library/src/androidTest/java/com/bumptech/glide/load/resource/gif/GifResourceDecoderTest.java
浏览文件 @
f0c8a95c
...
...
@@ -99,7 +99,6 @@ public class GifResourceDecoderTest {
verify
(
parserPool
).
release
(
eq
(
parser
));
}
@Test
public
void
testSetsPreferredConfigOnDecoderBeforeDecoding
()
{
when
(
gifHeader
.
getNumFrames
()).
thenReturn
(
1
);
...
...
@@ -148,6 +147,26 @@ public class GifResourceDecoderTest {
verify
(
decoderPool
).
release
(
eq
(
gifDecoder
));
}
@Test
public
void
testReturnsNullIfGifDecoderFailsToDecodeFirstFrame
()
{
when
(
gifHeader
.
getNumFrames
()).
thenReturn
(
1
);
when
(
gifHeader
.
getStatus
()).
thenReturn
(
GifDecoder
.
STATUS_OK
);
when
(
gifDecoder
.
getNextFrame
()).
thenReturn
(
null
);
assertNull
(
decoder
.
decode
(
new
ByteArrayInputStream
(
new
byte
[
0
]),
100
,
100
));
}
@Test
public
void
testReturnsGifDecoderToPoolWhenGifDecoderReturnsNullFirstFrame
()
{
when
(
gifHeader
.
getNumFrames
()).
thenReturn
(
1
);
when
(
gifHeader
.
getStatus
()).
thenReturn
(
GifDecoder
.
STATUS_OK
);
when
(
gifDecoder
.
getNextFrame
()).
thenReturn
(
null
);
decoder
.
decode
(
new
ByteArrayInputStream
(
new
byte
[
0
]),
100
,
100
);
verify
(
decoderPool
).
release
(
eq
(
gifDecoder
));
}
@Test
public
void
testCanObtainNonNullDecoderFromPool
()
{
GifDecoder
.
BitmapProvider
provider
=
mock
(
GifDecoder
.
BitmapProvider
.
class
);
...
...
library/src/main/java/com/bumptech/glide/load/resource/gif/GifFrameResourceDecoder.java
浏览文件 @
f0c8a95c
...
...
@@ -17,7 +17,11 @@ class GifFrameResourceDecoder implements ResourceDecoder<GifDecoder, Bitmap> {
@Override
public
Resource
<
Bitmap
>
decode
(
GifDecoder
source
,
int
width
,
int
height
)
{
Bitmap
bitmap
=
source
.
getNextFrame
();
return
new
BitmapResource
(
bitmap
,
bitmapPool
);
if
(
bitmap
==
null
)
{
return
null
;
}
else
{
return
new
BitmapResource
(
bitmap
,
bitmapPool
);
}
}
@Override
...
...
library/src/main/java/com/bumptech/glide/load/resource/gif/GifResourceDecoder.java
浏览文件 @
f0c8a95c
...
...
@@ -85,6 +85,10 @@ public class GifResourceDecoder implements ResourceDecoder<InputStream, GifDrawa
}
Bitmap
firstFrame
=
decodeFirstFrame
(
decoder
,
header
,
data
);
if
(
firstFrame
==
null
)
{
return
null
;
}
Transformation
<
Bitmap
>
unitTransformation
=
UnitTransformation
.
get
();
GifDrawable
gifDrawable
=
new
GifDrawable
(
context
,
provider
,
bitmapPool
,
unitTransformation
,
width
,
height
,
...
...
third_party/gif_decoder/src/main/java/com/bumptech/glide/gifdecoder/GifDecoder.java
浏览文件 @
f0c8a95c
...
...
@@ -250,9 +250,15 @@ public class GifDecoder {
*/
public
Bitmap
getNextFrame
()
{
if
(
header
.
frameCount
<=
0
||
framePointer
<
0
)
{
if
(
Log
.
isLoggable
(
TAG
,
Log
.
DEBUG
))
{
Log
.
d
(
TAG
,
"unable to decode frame, frameCount="
+
header
.
frameCount
+
" framePointer="
+
framePointer
);
}
status
=
STATUS_FORMAT_ERROR
;
}
if
(
status
==
STATUS_FORMAT_ERROR
||
status
==
STATUS_OPEN_ERROR
)
{
if
(
Log
.
isLoggable
(
TAG
,
Log
.
DEBUG
))
{
Log
.
d
(
TAG
,
"Unable to decode frame, status="
+
status
);
}
return
null
;
}
status
=
STATUS_OK
;
...
...
@@ -276,7 +282,9 @@ public class GifDecoder {
act
[
frame
.
transIndex
]
=
0
;
}
if
(
act
==
null
)
{
Log
.
w
(
TAG
,
"No Valid Color Table"
);
if
(
Log
.
isLoggable
(
TAG
,
Log
.
DEBUG
))
{
Log
.
d
(
TAG
,
"No Valid Color Table"
);
}
// No color table defined.
status
=
STATUS_FORMAT_ERROR
;
return
null
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录