Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
41281bb1
D
dragonwell8_jdk
项目概览
openanolis
/
dragonwell8_jdk
通知
3
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
dragonwell8_jdk
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
41281bb1
编写于
6月 11, 2009
作者:
B
bae
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
6296893: BMP Writer handles TopDown property incorrectly for some of the compression types
Reviewed-by: igor, prr
上级
78c78383
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
156 addition
and
3 deletion
+156
-3
src/share/classes/com/sun/imageio/plugins/bmp/BMPImageWriter.java
...e/classes/com/sun/imageio/plugins/bmp/BMPImageWriter.java
+14
-3
test/javax/imageio/plugins/bmp/TopDownTest.java
test/javax/imageio/plugins/bmp/TopDownTest.java
+142
-0
未找到文件。
src/share/classes/com/sun/imageio/plugins/bmp/BMPImageWriter.java
浏览文件 @
41281bb1
...
...
@@ -506,6 +506,19 @@ public class BMPImageWriter extends ImageWriter implements BMPConstants {
writeFileHeader
(
fileSize
,
offset
);
/* According to MSDN description, the top-down image layout
* is allowed only if compression type is BI_RGB or BI_BITFIELDS.
* Images with any other compression type must be wrote in the
* bottom-up layout.
*/
if
(
compressionType
==
BMPConstants
.
BI_RGB
||
compressionType
==
BMPConstants
.
BI_BITFIELDS
)
{
isTopDown
=
bmpParam
.
isTopDown
();
}
else
{
isTopDown
=
false
;
}
writeInfoHeader
(
headerSize
,
bitsPerPixel
);
// compression
...
...
@@ -588,8 +601,6 @@ public class BMPImageWriter extends ImageWriter implements BMPConstants {
return
;
}
isTopDown
=
bmpParam
.
isTopDown
();
int
maxBandOffset
=
bandOffsets
[
0
];
for
(
int
i
=
1
;
i
<
bandOffsets
.
length
;
i
++)
if
(
bandOffsets
[
i
]
>
maxBandOffset
)
...
...
@@ -1299,7 +1310,7 @@ public class BMPImageWriter extends ImageWriter implements BMPConstants {
stream
.
writeInt
(
w
);
// height
stream
.
writeInt
(
h
);
stream
.
writeInt
(
isTopDown
?
-
h
:
h
);
// number of planes
stream
.
writeShort
(
1
);
...
...
test/javax/imageio/plugins/bmp/TopDownTest.java
0 → 100644
浏览文件 @
41281bb1
/*
* Copyright 2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
/**
* @test
* @bug 6296893
* @summary Test verifies that the isTopDown flag does not cause
* a writing of bmp image in wrong scanline layout.
* @run main TopDownTest
*/
import
java.awt.Color
;
import
java.awt.Graphics
;
import
java.awt.image.BufferedImage
;
import
java.awt.image.IndexColorModel
;
import
java.io.File
;
import
java.io.IOException
;
import
javax.imageio.IIOImage
;
import
javax.imageio.ImageIO
;
import
javax.imageio.ImageWriteParam
;
import
javax.imageio.ImageWriter
;
import
javax.imageio.plugins.bmp.BMPImageWriteParam
;
import
javax.imageio.stream.ImageOutputStream
;
import
static
java
.
awt
.
image
.
BufferedImage
.
TYPE_INT_RGB
;
import
static
java
.
awt
.
image
.
BufferedImage
.
TYPE_BYTE_INDEXED
;
public
class
TopDownTest
{
public
static
void
main
(
String
[]
args
)
throws
IOException
{
BufferedImage
src
=
createTestImage
(
24
);
writeWithCompression
(
src
,
"BI_BITFIELDS"
);
writeWithCompression
(
src
,
"BI_RGB"
);
src
=
createTestImage
(
8
);
writeWithCompression
(
src
,
"BI_RLE8"
);
src
=
createTestImage
(
4
);
writeWithCompression
(
src
,
"BI_RLE4"
);
}
private
static
void
writeWithCompression
(
BufferedImage
src
,
String
compression
)
throws
IOException
{
System
.
out
.
println
(
"Compression: "
+
compression
);
ImageWriter
writer
=
ImageIO
.
getImageWritersByFormatName
(
"BMP"
).
next
();
if
(
writer
==
null
)
{
throw
new
RuntimeException
(
"Test failed: no bmp writer available"
);
}
File
fout
=
File
.
createTempFile
(
compression
+
"_"
,
".bmp"
,
new
File
(
"."
));
ImageOutputStream
ios
=
ImageIO
.
createImageOutputStream
(
fout
);
writer
.
setOutput
(
ios
);
BMPImageWriteParam
param
=
(
BMPImageWriteParam
)
writer
.
getDefaultWriteParam
();
param
.
setCompressionMode
(
ImageWriteParam
.
MODE_EXPLICIT
);
param
.
setCompressionType
(
compression
);
param
.
setTopDown
(
true
);
writer
.
write
(
null
,
new
IIOImage
(
src
,
null
,
null
),
param
);
writer
.
dispose
();
ios
.
flush
();
ios
.
close
();
BufferedImage
dst
=
ImageIO
.
read
(
fout
);
verify
(
dst
);
}
private
static
void
verify
(
BufferedImage
dst
)
{
int
top_rgb
=
dst
.
getRGB
(
50
,
25
);
System
.
out
.
printf
(
"top_rgb: %x\n"
,
top_rgb
);
int
bot_rgb
=
dst
.
getRGB
(
50
,
75
);
System
.
out
.
printf
(
"bot_rgb: %x\n"
,
bot_rgb
);
// expect to see blue color on the top of image
if
(
top_rgb
!=
0xff0000ff
)
{
throw
new
RuntimeException
(
"Invaid top color: "
+
Integer
.
toHexString
(
bot_rgb
));
}
if
(
bot_rgb
!=
0xffff0000
)
{
throw
new
RuntimeException
(
"Invalid bottom color: "
+
Integer
.
toHexString
(
bot_rgb
));
}
}
private
static
BufferedImage
createTestImage
(
int
bpp
)
{
BufferedImage
img
=
null
;
switch
(
bpp
)
{
case
8
:
img
=
new
BufferedImage
(
100
,
100
,
TYPE_BYTE_INDEXED
);
break
;
case
4
:
{
byte
[]
r
=
new
byte
[
16
];
byte
[]
g
=
new
byte
[
16
];
byte
[]
b
=
new
byte
[
16
];
r
[
1
]
=
(
byte
)
0xff
;
b
[
0
]
=
(
byte
)
0xff
;
IndexColorModel
icm
=
new
IndexColorModel
(
4
,
16
,
r
,
g
,
b
);
img
=
new
BufferedImage
(
100
,
100
,
TYPE_BYTE_INDEXED
,
icm
);
}
break
;
case
24
:
default
:
img
=
new
BufferedImage
(
100
,
100
,
TYPE_INT_RGB
);
}
Graphics
g
=
img
.
createGraphics
();
g
.
setColor
(
Color
.
blue
);
g
.
fillRect
(
0
,
0
,
100
,
50
);
g
.
setColor
(
Color
.
red
);
g
.
fillRect
(
0
,
50
,
100
,
50
);
g
.
dispose
();
return
img
;
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录