Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
7fa33389
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看板
提交
7fa33389
编写于
4月 26, 2013
作者:
B
bae
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8012601: Better validation of image layouts
Reviewed-by: prr
上级
66d85601
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
42 addition
and
2 deletion
+42
-2
src/share/classes/java/awt/image/BufferedImage.java
src/share/classes/java/awt/image/BufferedImage.java
+1
-0
src/share/classes/sun/java2d/cmm/lcms/LCMSImageLayout.java
src/share/classes/sun/java2d/cmm/lcms/LCMSImageLayout.java
+41
-2
未找到文件。
src/share/classes/java/awt/image/BufferedImage.java
浏览文件 @
7fa33389
...
@@ -776,6 +776,7 @@ public class BufferedImage extends java.awt.Image
...
@@ -776,6 +776,7 @@ public class BufferedImage extends java.awt.Image
}
}
}
}
if
(
is8bit
&&
if
(
is8bit
&&
braster
.
getPixelStride
()
==
numBands
&&
offs
[
0
]
==
numBands
-
1
&&
offs
[
0
]
==
numBands
-
1
&&
offs
[
1
]
==
numBands
-
2
&&
offs
[
1
]
==
numBands
-
2
&&
offs
[
2
]
==
numBands
-
3
)
offs
[
2
]
==
numBands
-
3
)
...
...
src/share/classes/sun/java2d/cmm/lcms/LCMSImageLayout.java
浏览文件 @
7fa33389
...
@@ -76,6 +76,7 @@ class LCMSImageLayout {
...
@@ -76,6 +76,7 @@ class LCMSImageLayout {
int
width
;
int
width
;
int
height
;
int
height
;
int
nextRowOffset
;
int
nextRowOffset
;
private
int
nextPixelOffset
;
int
offset
;
int
offset
;
/* This flag indicates whether the image can be processed
/* This flag indicates whether the image can be processed
...
@@ -93,6 +94,7 @@ class LCMSImageLayout {
...
@@ -93,6 +94,7 @@ class LCMSImageLayout {
this
.
pixelType
=
pixelType
;
this
.
pixelType
=
pixelType
;
width
=
np
;
width
=
np
;
height
=
1
;
height
=
1
;
nextPixelOffset
=
pixelSize
;
nextRowOffset
=
safeMult
(
pixelSize
,
np
);
nextRowOffset
=
safeMult
(
pixelSize
,
np
);
offset
=
0
;
offset
=
0
;
}
}
...
@@ -104,6 +106,7 @@ class LCMSImageLayout {
...
@@ -104,6 +106,7 @@ class LCMSImageLayout {
this
.
pixelType
=
pixelType
;
this
.
pixelType
=
pixelType
;
this
.
width
=
width
;
this
.
width
=
width
;
this
.
height
=
height
;
this
.
height
=
height
;
nextPixelOffset
=
pixelSize
;
nextRowOffset
=
safeMult
(
pixelSize
,
width
);
nextRowOffset
=
safeMult
(
pixelSize
,
width
);
offset
=
0
;
offset
=
0
;
}
}
...
@@ -221,6 +224,7 @@ class LCMSImageLayout {
...
@@ -221,6 +224,7 @@ class LCMSImageLayout {
IntegerComponentRaster
intRaster
=
(
IntegerComponentRaster
)
IntegerComponentRaster
intRaster
=
(
IntegerComponentRaster
)
image
.
getRaster
();
image
.
getRaster
();
l
.
nextRowOffset
=
safeMult
(
4
,
intRaster
.
getScanlineStride
());
l
.
nextRowOffset
=
safeMult
(
4
,
intRaster
.
getScanlineStride
());
l
.
nextPixelOffset
=
safeMult
(
4
,
intRaster
.
getPixelStride
());
l
.
offset
=
safeMult
(
4
,
intRaster
.
getDataOffset
(
0
));
l
.
offset
=
safeMult
(
4
,
intRaster
.
getDataOffset
(
0
));
l
.
dataArray
=
intRaster
.
getDataStorage
();
l
.
dataArray
=
intRaster
.
getDataStorage
();
l
.
dataArrayLength
=
4
*
intRaster
.
getDataStorage
().
length
;
l
.
dataArrayLength
=
4
*
intRaster
.
getDataStorage
().
length
;
...
@@ -238,6 +242,8 @@ class LCMSImageLayout {
...
@@ -238,6 +242,8 @@ class LCMSImageLayout {
ByteComponentRaster
byteRaster
=
(
ByteComponentRaster
)
ByteComponentRaster
byteRaster
=
(
ByteComponentRaster
)
image
.
getRaster
();
image
.
getRaster
();
l
.
nextRowOffset
=
byteRaster
.
getScanlineStride
();
l
.
nextRowOffset
=
byteRaster
.
getScanlineStride
();
l
.
nextPixelOffset
=
byteRaster
.
getPixelStride
();
int
firstBand
=
image
.
getSampleModel
().
getNumBands
()
-
1
;
int
firstBand
=
image
.
getSampleModel
().
getNumBands
()
-
1
;
l
.
offset
=
byteRaster
.
getDataOffset
(
firstBand
);
l
.
offset
=
byteRaster
.
getDataOffset
(
firstBand
);
l
.
dataArray
=
byteRaster
.
getDataStorage
();
l
.
dataArray
=
byteRaster
.
getDataStorage
();
...
@@ -254,6 +260,8 @@ class LCMSImageLayout {
...
@@ -254,6 +260,8 @@ class LCMSImageLayout {
ByteComponentRaster
byteRaster
=
(
ByteComponentRaster
)
ByteComponentRaster
byteRaster
=
(
ByteComponentRaster
)
image
.
getRaster
();
image
.
getRaster
();
l
.
nextRowOffset
=
byteRaster
.
getScanlineStride
();
l
.
nextRowOffset
=
byteRaster
.
getScanlineStride
();
l
.
nextPixelOffset
=
byteRaster
.
getPixelStride
();
l
.
dataArrayLength
=
byteRaster
.
getDataStorage
().
length
;
l
.
dataArrayLength
=
byteRaster
.
getDataStorage
().
length
;
l
.
offset
=
byteRaster
.
getDataOffset
(
0
);
l
.
offset
=
byteRaster
.
getDataOffset
(
0
);
l
.
dataArray
=
byteRaster
.
getDataStorage
();
l
.
dataArray
=
byteRaster
.
getDataStorage
();
...
@@ -270,6 +278,8 @@ class LCMSImageLayout {
...
@@ -270,6 +278,8 @@ class LCMSImageLayout {
ShortComponentRaster
shortRaster
=
(
ShortComponentRaster
)
ShortComponentRaster
shortRaster
=
(
ShortComponentRaster
)
image
.
getRaster
();
image
.
getRaster
();
l
.
nextRowOffset
=
safeMult
(
2
,
shortRaster
.
getScanlineStride
());
l
.
nextRowOffset
=
safeMult
(
2
,
shortRaster
.
getScanlineStride
());
l
.
nextPixelOffset
=
safeMult
(
2
,
shortRaster
.
getPixelStride
());
l
.
offset
=
safeMult
(
2
,
shortRaster
.
getDataOffset
(
0
));
l
.
offset
=
safeMult
(
2
,
shortRaster
.
getDataOffset
(
0
));
l
.
dataArray
=
shortRaster
.
getDataStorage
();
l
.
dataArray
=
shortRaster
.
getDataStorage
();
l
.
dataArrayLength
=
2
*
shortRaster
.
getDataStorage
().
length
;
l
.
dataArrayLength
=
2
*
shortRaster
.
getDataStorage
().
length
;
...
@@ -331,9 +341,15 @@ class LCMSImageLayout {
...
@@ -331,9 +341,15 @@ class LCMSImageLayout {
throw
new
ImageLayoutException
(
"Invalid image layout"
);
throw
new
ImageLayoutException
(
"Invalid image layout"
);
}
}
int
lastPixelOffset
=
safeMult
(
nextRowOffset
,
(
height
-
1
));
if
(
nextPixelOffset
!=
getBytesPerPixel
(
pixelType
))
{
throw
new
ImageLayoutException
(
"Invalid image layout"
);
}
int
lastScanOffset
=
safeMult
(
nextRowOffset
,
(
height
-
1
));
lastPixelOffset
=
safeAdd
(
lastPixelOffset
,
(
width
-
1
));
int
lastPixelOffset
=
safeMult
(
nextPixelOffset
,
(
width
-
1
));
lastPixelOffset
=
safeAdd
(
lastPixelOffset
,
lastScanOffset
);
int
off
=
safeAdd
(
offset
,
lastPixelOffset
);
int
off
=
safeAdd
(
offset
,
lastPixelOffset
);
...
@@ -392,6 +408,8 @@ class LCMSImageLayout {
...
@@ -392,6 +408,8 @@ class LCMSImageLayout {
}
}
l
.
nextRowOffset
=
br
.
getScanlineStride
();
l
.
nextRowOffset
=
br
.
getScanlineStride
();
l
.
nextPixelOffset
=
br
.
getPixelStride
();
l
.
offset
=
br
.
getDataOffset
(
firstBand
);
l
.
offset
=
br
.
getDataOffset
(
firstBand
);
l
.
dataArray
=
br
.
getDataStorage
();
l
.
dataArray
=
br
.
getDataStorage
();
l
.
dataType
=
DT_BYTE
;
l
.
dataType
=
DT_BYTE
;
...
@@ -406,4 +424,25 @@ class LCMSImageLayout {
...
@@ -406,4 +424,25 @@ class LCMSImageLayout {
}
}
return
null
;
return
null
;
}
}
/**
* Derives number of bytes per pixel from the pixel format.
* Following bit fields are used here:
* [0..2] - bytes per sample
* [3..6] - number of color samples per pixel
* [7..9] - number of non-color samples per pixel
*
* A complete description of the pixel format can be found
* here: lcms2.h, lines 651 - 667.
*
* @param pixelType pixel format in lcms2 notation.
* @return number of bytes per pixel for given pixel format.
*/
private
static
int
getBytesPerPixel
(
int
pixelType
)
{
int
bytesPerSample
=
(
0x7
&
pixelType
);
int
colorSamplesPerPixel
=
0xF
&
(
pixelType
>>
3
);
int
extraSamplesPerPixel
=
0x7
&
(
pixelType
>>
7
);
return
bytesPerSample
*
(
colorSamplesPerPixel
+
extraSamplesPerPixel
);
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录