Browse Source

REPORT-31938 改进

release/10.0
Hugh.C 5 years ago
parent
commit
afd604622c
  1. 20
      fine-itext-old/src/com/fr/third/com/lowagie/text/html/WebColors.java
  2. 20
      fine-itext/src/com/fr/third/v2/lowagie/text/html/WebColors.java

20
fine-itext-old/src/com/fr/third/com/lowagie/text/html/WebColors.java

@ -272,7 +272,7 @@ public class WebColors extends HashMap {
c[k] = parseColorValue(tok.nextToken());
}
try {
c[3] = parseColorValue(tok.nextToken());
c[3] = parseAlphaValue(tok.nextToken());
} catch (Exception e) {
//alpha 值可写可不写
}
@ -287,6 +287,24 @@ public class WebColors extends HashMap {
}
/**
* 转化 alpha
* @param v
* @return 0~ 255
*/
public static int parseAlphaValue(String v) {
if (v.endsWith("%")) {
return parseColorValue(v);
}
float r = Float.parseFloat(v) * 255;
if (r < 0)
r = 0;
else if (r > 255)
r = 255;
return (int) r;
}
/**
* 转化 rgb
* @param v
* @return 0~ 255
*/

20
fine-itext/src/com/fr/third/v2/lowagie/text/html/WebColors.java

@ -272,7 +272,7 @@ public class WebColors extends HashMap {
c[k] = parseColorValue(tok.nextToken());
}
try {
c[3] = parseColorValue(tok.nextToken());
c[3] = parseAlphaValue(tok.nextToken());
} catch (Exception e) {
//alpha 值可写可不写
}
@ -287,6 +287,24 @@ public class WebColors extends HashMap {
}
/**
* 转化 alpha
* @param v
* @return 0~ 255
*/
public static int parseAlphaValue(String v) {
if (v.endsWith("%")) {
return parseColorValue(v);
}
float r = Float.parseFloat(v) * 255;
if (r < 0)
r = 0;
else if (r > 255)
r = 255;
return (int) r;
}
/**
* 转化 rgb
* @param v
* @return 0~ 255
*/

Loading…
Cancel
Save