Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jsf-2/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Primefaces 6.1带黑色背景的png图像显示_Primefaces_Jsf 2_Background_Png_Transparent - Fatal编程技术网

Primefaces 6.1带黑色背景的png图像显示

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。我的问

我很难在PrimeFaces 6.1中显示png图像

图像是以字节数组格式从数据库加载的。jpg显示良好,但png始终以黑色背景显示

这是我的jsf代码片段:

<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());
    }
}