Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
599f76a4
D
dragonwell8_jdk
项目概览
openanolis
/
dragonwell8_jdk
通知
4
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看板
提交
599f76a4
编写于
5月 19, 2014
作者:
A
anashaty
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8038000: java.awt.image.RasterFormatException: Incorrect scanline stride
Reviewed-by: bae, serb
上级
7f8080b7
变更
7
显示空白变更内容
内联
并排
Showing
7 changed file
with
255 addition
and
16 deletion
+255
-16
src/share/classes/sun/awt/image/ByteBandedRaster.java
src/share/classes/sun/awt/image/ByteBandedRaster.java
+16
-4
src/share/classes/sun/awt/image/ByteComponentRaster.java
src/share/classes/sun/awt/image/ByteComponentRaster.java
+18
-2
src/share/classes/sun/awt/image/BytePackedRaster.java
src/share/classes/sun/awt/image/BytePackedRaster.java
+17
-2
src/share/classes/sun/awt/image/IntegerComponentRaster.java
src/share/classes/sun/awt/image/IntegerComponentRaster.java
+18
-2
src/share/classes/sun/awt/image/ShortBandedRaster.java
src/share/classes/sun/awt/image/ShortBandedRaster.java
+15
-4
src/share/classes/sun/awt/image/ShortComponentRaster.java
src/share/classes/sun/awt/image/ShortComponentRaster.java
+18
-2
test/sun/awt/image/bug8038000.java
test/sun/awt/image/bug8038000.java
+153
-0
未找到文件。
src/share/classes/sun/awt/image/ByteBandedRaster.java
浏览文件 @
599f76a4
...
...
@@ -755,12 +755,24 @@ public class ByteBandedRaster extends SunWritableRaster {
+
scanlineStride
);
}
if
((
long
)
minX
-
sampleModelTranslateX
<
0
||
(
long
)
minY
-
sampleModelTranslateY
<
0
)
{
throw
new
RasterFormatException
(
"Incorrect origin/translate: ("
+
minX
+
", "
+
minY
+
") / ("
+
sampleModelTranslateX
+
", "
+
sampleModelTranslateY
+
")"
);
}
if
(
height
>
1
||
minY
-
sampleModelTranslateY
>
0
)
{
// buffer should contain at least one scanline
for
(
int
i
=
0
;
i
<
data
.
length
;
i
++)
{
if
(
scanlineStride
>
data
[
i
].
length
)
{
throw
new
RasterFormatException
(
"Incorrect scanline stride: "
+
scanlineStride
);
}
}
}
// Make sure data for Raster is in a legal range
for
(
int
i
=
0
;
i
<
dataOffsets
.
length
;
i
++)
{
...
...
src/share/classes/sun/awt/image/ByteComponentRaster.java
浏览文件 @
599f76a4
...
...
@@ -885,15 +885,31 @@ public class ByteComponentRaster extends SunWritableRaster {
}
}
if
((
long
)
minX
-
sampleModelTranslateX
<
0
||
(
long
)
minY
-
sampleModelTranslateY
<
0
)
{
throw
new
RasterFormatException
(
"Incorrect origin/translate: ("
+
minX
+
", "
+
minY
+
") / ("
+
sampleModelTranslateX
+
", "
+
sampleModelTranslateY
+
")"
);
}
// we can be sure that width and height are greater than 0
if
(
scanlineStride
<
0
||
scanlineStride
>
(
Integer
.
MAX_VALUE
/
height
)
||
scanlineStride
>
data
.
length
)
scanlineStride
>
(
Integer
.
MAX_VALUE
/
height
))
{
// integer overflow
throw
new
RasterFormatException
(
"Incorrect scanline stride: "
+
scanlineStride
);
}
if
(
height
>
1
||
minY
-
sampleModelTranslateY
>
0
)
{
// buffer should contain at least one scanline
if
(
scanlineStride
>
data
.
length
)
{
throw
new
RasterFormatException
(
"Incorrect scanline stride: "
+
scanlineStride
);
}
}
int
lastScanOffset
=
(
height
-
1
)
*
scanlineStride
;
if
(
pixelStride
<
0
||
...
...
src/share/classes/sun/awt/image/BytePackedRaster.java
浏览文件 @
599f76a4
...
...
@@ -1386,13 +1386,28 @@ public class BytePackedRaster extends SunWritableRaster {
throw
new
RasterFormatException
(
"Invalid raster dimension"
);
}
if
((
long
)
minX
-
sampleModelTranslateX
<
0
||
(
long
)
minY
-
sampleModelTranslateY
<
0
)
{
throw
new
RasterFormatException
(
"Incorrect origin/translate: ("
+
minX
+
", "
+
minY
+
") / ("
+
sampleModelTranslateX
+
", "
+
sampleModelTranslateY
+
")"
);
}
if
(
scanlineStride
<
0
||
scanlineStride
>
(
Integer
.
MAX_VALUE
/
height
)
||
scanlineStride
>
data
.
length
)
scanlineStride
>
(
Integer
.
MAX_VALUE
/
height
))
{
throw
new
RasterFormatException
(
"Invalid scanline stride"
);
}
if
(
height
>
1
||
minY
-
sampleModelTranslateY
>
0
)
{
// buffer should contain at least one scanline
if
(
scanlineStride
>
data
.
length
)
{
throw
new
RasterFormatException
(
"Incorrect scanline stride: "
+
scanlineStride
);
}
}
int
lastbit
=
(
dataBitOffset
+
(
height
-
1
)
*
scanlineStride
*
8
+
(
width
-
1
)
*
pixelBitStride
...
...
src/share/classes/sun/awt/image/IntegerComponentRaster.java
浏览文件 @
599f76a4
...
...
@@ -654,15 +654,31 @@ public class IntegerComponentRaster extends SunWritableRaster {
") must be >= 0"
);
}
if
((
long
)
minX
-
sampleModelTranslateX
<
0
||
(
long
)
minY
-
sampleModelTranslateY
<
0
)
{
throw
new
RasterFormatException
(
"Incorrect origin/translate: ("
+
minX
+
", "
+
minY
+
") / ("
+
sampleModelTranslateX
+
", "
+
sampleModelTranslateY
+
")"
);
}
// we can be sure that width and height are greater than 0
if
(
scanlineStride
<
0
||
scanlineStride
>
(
Integer
.
MAX_VALUE
/
height
)
||
scanlineStride
>
data
.
length
)
scanlineStride
>
(
Integer
.
MAX_VALUE
/
height
))
{
// integer overflow
throw
new
RasterFormatException
(
"Incorrect scanline stride: "
+
scanlineStride
);
}
if
(
height
>
1
||
minY
-
sampleModelTranslateY
>
0
)
{
// buffer should contain at least one scanline
if
(
scanlineStride
>
data
.
length
)
{
throw
new
RasterFormatException
(
"Incorrect scanline stride: "
+
scanlineStride
);
}
}
int
lastScanOffset
=
(
height
-
1
)
*
scanlineStride
;
if
(
pixelStride
<
0
||
...
...
src/share/classes/sun/awt/image/ShortBandedRaster.java
浏览文件 @
599f76a4
...
...
@@ -754,12 +754,23 @@ public class ShortBandedRaster extends SunWritableRaster {
+
scanlineStride
);
}
if
((
long
)
minX
-
sampleModelTranslateX
<
0
||
(
long
)
minY
-
sampleModelTranslateY
<
0
)
{
throw
new
RasterFormatException
(
"Incorrect origin/translate: ("
+
minX
+
", "
+
minY
+
") / ("
+
sampleModelTranslateX
+
", "
+
sampleModelTranslateY
+
")"
);
}
if
(
height
>
1
||
minY
-
sampleModelTranslateY
>
0
)
{
// buffer should contain at least one scanline
for
(
int
i
=
0
;
i
<
data
.
length
;
i
++)
{
if
(
scanlineStride
>
data
[
i
].
length
)
{
throw
new
RasterFormatException
(
"Incorrect scanline stride: "
+
scanlineStride
);
}
}
}
// Make sure data for Raster is in a legal range
for
(
int
i
=
0
;
i
<
dataOffsets
.
length
;
i
++)
{
...
...
src/share/classes/sun/awt/image/ShortComponentRaster.java
浏览文件 @
599f76a4
...
...
@@ -819,15 +819,31 @@ public class ShortComponentRaster extends SunWritableRaster {
}
}
if
((
long
)
minX
-
sampleModelTranslateX
<
0
||
(
long
)
minY
-
sampleModelTranslateY
<
0
)
{
throw
new
RasterFormatException
(
"Incorrect origin/translate: ("
+
minX
+
", "
+
minY
+
") / ("
+
sampleModelTranslateX
+
", "
+
sampleModelTranslateY
+
")"
);
}
// we can be sure that width and height are greater than 0
if
(
scanlineStride
<
0
||
scanlineStride
>
(
Integer
.
MAX_VALUE
/
height
)
||
scanlineStride
>
data
.
length
)
scanlineStride
>
(
Integer
.
MAX_VALUE
/
height
))
{
// integer overflow
throw
new
RasterFormatException
(
"Incorrect scanline stride: "
+
scanlineStride
);
}
if
(
height
>
1
||
minY
-
sampleModelTranslateY
>
0
)
{
// buffer should contain at least one scanline
if
(
scanlineStride
>
data
.
length
)
{
throw
new
RasterFormatException
(
"Incorrect scanline stride: "
+
scanlineStride
);
}
}
int
lastScanOffset
=
(
height
-
1
)
*
scanlineStride
;
if
(
pixelStride
<
0
||
...
...
test/sun/awt/image/bug8038000.java
0 → 100644
浏览文件 @
599f76a4
/*
* Copyright (c) 2014, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* @test
* @bug 8038000
*
* @summary Verifies that we could create different type of Rasters with height 1
* and strideline which exceeds raster width.
* Also checks that a set of RasterOp work correctly with such kind of Rasters.
*
* @run main bug8038000
*/
import
java.awt.*
;
import
java.awt.color.ColorSpace
;
import
java.awt.geom.AffineTransform
;
import
java.awt.image.*
;
import
java.util.Arrays
;
public
class
bug8038000
{
public
static
void
main
(
String
[]
args
)
throws
Exception
{
new
bug8038000
().
checkOps
();
// No exceptions - Passed
}
private
void
checkOps
()
throws
Exception
{
RasterOp
[]
ops
=
new
RasterOp
[]
{
new
ColorConvertOp
(
ColorSpace
.
getInstance
(
ColorSpace
.
CS_sRGB
),
ColorSpace
.
getInstance
(
ColorSpace
.
CS_LINEAR_RGB
),
null
),
new
AffineTransformOp
(
AffineTransform
.
getScaleInstance
(
1
,
1.1
),
null
)
};
for
(
RasterOp
op:
ops
)
{
// Banded rasters
checkOp
(
Raster
.
createBandedRaster
(
DataBuffer
.
TYPE_BYTE
,
10
,
1
,
10
,
new
int
[]
{
0
,
1
,
2
},
new
int
[]{
2
,
1
,
0
},
null
),
Raster
.
createBandedRaster
(
DataBuffer
.
TYPE_BYTE
,
10
,
1
,
1001
,
new
int
[]
{
0
,
1
,
2
},
new
int
[]{
2
,
1
,
0
},
null
),
op
);
checkOp
(
Raster
.
createBandedRaster
(
DataBuffer
.
TYPE_USHORT
,
10
,
1
,
10
,
new
int
[]
{
0
,
1
,
2
},
new
int
[]{
2
,
1
,
0
},
null
),
Raster
.
createBandedRaster
(
DataBuffer
.
TYPE_USHORT
,
10
,
1
,
1001
,
new
int
[]
{
0
,
1
,
2
},
new
int
[]{
2
,
1
,
0
},
null
),
op
);
checkOp
(
Raster
.
createBandedRaster
(
DataBuffer
.
TYPE_INT
,
10
,
1
,
10
,
new
int
[]
{
0
,
1
,
2
},
new
int
[]{
2
,
1
,
0
},
null
),
Raster
.
createBandedRaster
(
DataBuffer
.
TYPE_INT
,
10
,
1
,
1001
,
new
int
[]
{
0
,
1
,
2
},
new
int
[]{
2
,
1
,
0
},
null
),
op
);
// Interleaved rasters
checkOp
(
Raster
.
createInterleavedRaster
(
DataBuffer
.
TYPE_BYTE
,
10
,
1
,
30
,
3
,
new
int
[]{
0
,
1
,
2
},
null
),
Raster
.
createInterleavedRaster
(
DataBuffer
.
TYPE_BYTE
,
10
,
1
,
1001
,
3
,
new
int
[]{
0
,
1
,
2
},
null
),
op
);
checkOp
(
Raster
.
createInterleavedRaster
(
DataBuffer
.
TYPE_USHORT
,
10
,
1
,
30
,
3
,
new
int
[]{
0
,
1
,
2
},
null
),
Raster
.
createInterleavedRaster
(
DataBuffer
.
TYPE_USHORT
,
10
,
1
,
1001
,
3
,
new
int
[]{
0
,
1
,
2
},
null
),
op
);
// Packed rasters
checkOp
(
Raster
.
createPackedRaster
(
new
DataBufferByte
(
10
),
10
,
1
,
10
,
new
int
[]
{
0x01
,
0x02
,
0x04
},
null
),
Raster
.
createPackedRaster
(
new
DataBufferByte
(
10
),
10
,
1
,
2000
,
new
int
[]
{
0x01
,
0x02
,
0x04
},
null
),
op
);
checkOp
(
Raster
.
createPackedRaster
(
new
DataBufferInt
(
10
),
10
,
1
,
10
,
new
int
[]
{
0xff0000
,
0x00ff00
,
0x0000ff
},
null
),
Raster
.
createPackedRaster
(
new
DataBufferInt
(
10
),
10
,
1
,
20
,
new
int
[]
{
0xff0000
,
0x00ff00
,
0x0000ff
},
null
),
op
);
}
}
/**
* Takes two identical rasters (identical with the exception of scanline stride)
* fills their pixels with identical data, applies the RasterOp to both rasters
* and checks that the result is the same
*/
private
void
checkOp
(
WritableRaster
wr1
,
WritableRaster
wr2
,
RasterOp
op
)
{
System
.
out
.
println
(
"Checking "
+
op
+
" with rasters: \n "
+
wr1
+
"\n "
+
wr2
);
try
{
WritableRaster
r1
=
op
.
filter
(
fillRaster
(
wr1
),
null
);
WritableRaster
r2
=
op
.
filter
(
fillRaster
(
wr2
),
null
);
compareRasters
(
r1
,
r2
);
}
catch
(
ImagingOpException
e
)
{
System
.
out
.
println
(
" Skip: Op is not supported: "
+
e
);
}
}
private
WritableRaster
fillRaster
(
WritableRaster
wr
)
{
int
c
=
0
;
for
(
int
x
=
wr
.
getMinX
();
x
<
wr
.
getMinX
()
+
wr
.
getWidth
();
x
++)
{
for
(
int
y
=
wr
.
getMinY
();
y
<
wr
.
getMinY
()
+
wr
.
getHeight
();
y
++)
{
for
(
int
b
=
0
;
b
<
wr
.
getNumBands
();
b
++)
{
wr
.
setSample
(
x
,
y
,
b
,
c
++);
}
}
}
return
wr
;
}
private
void
compareRasters
(
Raster
r1
,
Raster
r2
)
{
Rectangle
bounds
=
r1
.
getBounds
();
if
(!
bounds
.
equals
(
r2
.
getBounds
()))
{
throw
new
RuntimeException
(
"Bounds differ."
);
}
if
(
r1
.
getNumBands
()
!=
r2
.
getNumBands
())
{
throw
new
RuntimeException
(
"Bands differ."
);
}
int
[]
b1
=
new
int
[
r1
.
getNumBands
()];
int
[]
b2
=
new
int
[
r1
.
getNumBands
()];
for
(
int
x
=
(
int
)
bounds
.
getX
();
x
<
bounds
.
getMaxX
();
x
++)
{
for
(
int
y
=
(
int
)
bounds
.
getY
();
y
<
bounds
.
getMaxY
();
y
++)
{
r1
.
getPixel
(
x
,
y
,
b1
);
r2
.
getPixel
(
x
,
y
,
b2
);
if
(!
Arrays
.
equals
(
b1
,
b2
))
{
throw
new
RuntimeException
(
"Pixels differ."
);
}
}
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录