Primefaces 6.1带黑色背景的png图像显示
我很难在PrimeFaces 6.1中显示png图像 图像是以字节数组格式从数据库加载的。jpg显示良好,但png始终以黑色背景显示 这是我的jsf代码片段:Primefaces 6.1带黑色背景的png图像显示,primefaces,jsf-2,background,png,transparent,Primefaces,Jsf 2,Background,Png,Transparent,我很难在PrimeFaces 6.1中显示png图像 图像是以字节数组格式从数据库加载的。jpg显示良好,但png始终以黑色背景显示 这是我的jsf代码片段: <p:graphicImage value="#{fileControlBean.image}"> <f:param name="fileId" value="#{file.fileId}" /> </p:graphicImage> 所有其他jpg显示正确,但png图像看起来透明设置为1。我的问
<p:graphicImage value="#{fileControlBean.image}">
<f:param name="fileId" value="#{file.fileId}" />
</p:graphicImage>
所有其他jpg显示正确,但png图像看起来透明设置为1。我的问题是:如何将其设置回透明?或者它是一个bug?对不起,这个任务没有被正确地询问。黑色背景问题是png自身造成的,因为它与透明度问题有关。我使用inkscape重新生成png。黑色背景消失了。抱歉,此任务未正确询问。黑色背景问题是png自身造成的,因为它与透明度问题有关。我使用inkscape重新生成png。黑色背景消失了
public StreamedContent getImage() throws IOException {
FacesContext context = FacesContext.getCurrentInstance();
if (context.getCurrentPhaseId() == PhaseId.RENDER_RESPONSE) {
// So, we're rendering the HTML. Return a stub StreamedContent so that it will generate right URL.
return new DefaultStreamedContent();
}
else {
// So, browser is requesting the image. Return a real StreamedContent with the image bytes.
String fileId = context.getExternalContext().getRequestParameterMap().get("fileId");
File file = (File) fileBean.getFileCache().get(fileId);
return new ByteArrayContent(file.getThumbnail(),file.getFileType(),file.getFileName());
}
}