当前位置: 首页 > 知识库问答 >
问题:

代号一个来自互联网来源的圆角图像

聂涛
2023-03-14

但是我似乎不明白为什么在标签上调用setmask也不起作用。

   // Create MASK

    Image maskImage = Image.createImage(w, l);
    Graphics g = maskImage.getGraphics();
    g.setAntiAliased(true);
    g.setColor(0x000000);
    g.fillRect(0, 0, w, l);
    g.setColor(0xffffff);
    g.fillArc(0, 0, w, l, 0, 360);
    Object mask = maskImage.createMask();



    // GET IMAGE
    com.cloudinary.Cloudinary cloudinary = new com.cloudinary.Cloudinary(ObjectUtils.asMap(
            "cloud_name", "REMOVED",
            "api_key", "REMOVED",
            "api_secret", "REMOVED"));
    // Disable private CDN URLs as this doesn't seem to work with free accounts
    cloudinary.config.privateCdn = false;
    Image placeholder = Image.createImage(150, 150);
    EncodedImage encImage = EncodedImage.createFromImage(placeholder, false);
    Image img2 = cloudinary.url()
            .type("fetch") // Says we are fetching an image
            .format("jpg") // We want it to be a jpg
            .transformation(
                    new Transformation()
                    .radius("max").width(150).height(150).crop("thumb").gravity("faces").image(encImage, "http://upload.wikimedia.org/wikipedia/commons/4/46/Jennifer_Lawrence_at_the_83rd_Academy_Awards.jpg");

    Label label = new Label(img2);
    label.setMask(mask);  // also tried to do img2.applyMask(mask); before passing img2 

共有1个答案

逑阳泽
2023-03-14

所以我尝试了各种各样的事情:

1)移除通过cloudinary设置的掩膜--这不起作用

2)将掩码应用于占位符&编码图像(正如预期的那样,这些掩码不会影响即将发布的最终版本)

    Label label = new Label();
    img2.applyMask(mask);  // If you remove this line , the image will no longer be displayed, I will only see a rounded white circle ! I am not sure what this is doing, it might be simply stalling the process until the image is downloaded? or maybe somehow calling repaint or revalidate
    label.setIcon( img2.applyMask(mask));
        //CREATE MASK
    Image maskImage = Image.createImage(w, l);
    Graphics g = maskImage.getGraphics();
    g.setAntiAliased(true);
    g.setColor(0x000000);
    g.fillRect(0, 0, w, l);
    g.setColor(0xffffff);
    g.fillArc(0, 0, w, l, 0, 360);
    Object mask = maskImage.createMask();

    //CONNECT TO CLOUDINARY 
    com.cloudinary.Cloudinary cloudinary = new com.cloudinary.Cloudinary(ObjectUtils.asMap(
            "cloud_name", "REMOVED",
            "api_key", "REMOVED",
            "api_secret", "REMOVED"));
    // Disable private CDN URLs as this doesn't seem to work with free accounts
    cloudinary.config.privateCdn = false;

    //CREATE IMAGE PLACEHOLDERS 
    Image placeholder = Image.createImage(w, l);
    EncodedImage encImage = EncodedImage.createFromImage(placeholder, false);

    //DOWNLOAD IMAGE
    Image img2 = cloudinary.url()
            .type("fetch") // Says we are fetching an image
            .format("jpg") // We want it to be a jpg
            .transformation(
                    new Transformation()
                    .crop("thumb").gravity("faces")
                    .image(encImage, url);


    // Add the image to a label and place it on the form.
    //GetCircleImage(img2);
    Label label = new Label();
    img2.applyMask(mask);   // If you remove this line , the image will no longer be displayed, I will only see a rounded white circle ! I am not sure what this is doing, it might be simply stalling the process until the image is downloaded? or maybe somehow calling repaint or revalidate
    label.setIcon( img2.applyMask(mask));
 类似资料:
  • 如何修改此ffmpeg字符串以生成具有不同视频比特率的多个输出?这是为了在yadif=1消耗大量电力时节省时间。而且,无法让它在windows中接受yadif_cuda。 ffmpeg-y-f lavfi-i anullsrc=cl=mono:sample_rate=48000-i“test.mxf”-vf yadif=1-s 1920:1080-c:v h264-nvenc-强制关键帧“expr

  • 问题内容: class Match(Base): tablename = ‘matches’ 我需要编写一个查询,该查询将列和团队表连接在一起,以显示本地和客队的团队信息。 这返回 问题答案: 首先,您的代码不起作用的原因是因为SQLAlchemy不知道您是否要通过via或加入,因此您必须告诉它。此外,您需要加入两次,这使事情变得更加复杂。 使用以下命令可以更轻松地完成此操作: 并且将在相同的查询

  • 我目前正在使用Adruino Uno构建一个项目,以收集温度和湿度等天气数据,然后将这些数据传递到Azure IOT中心,然后对消息进行处理并再次存储到Azure中的SQL数据库。最后,数据会显示在一个网站上,用户可以注册并查看我收集的天气数据。 我正在尝试在系统中实现SMS通知,这样,如果温度达到某个阈值(例如0摄氏度),系统上的用户将收到SMS消息,通知他们寒冷的温度。 我的问题是SMS消息的

  • 出于某种原因,我一直在GradleJavaFX项目中获得NPE。 我的文件夹结构非常基本。我在文件夹中有一个包含java文件的包。我的资源也在文件夹中。当我尝试加载它给了我一个NPE。 这是一个助手类。 从我调用:

  • 这是我的第一个帖子。作为一名初出茅庐的Android开发者,我几乎每天都在阅读各种主题的SO帖子,但对于这个问题,我没有从谷歌那里找到任何帮助。 我到目前为止的研究: 搜索这个问题比正常情况要难,因为搜索引擎似乎不关心大小写敏感性,而大小写敏感性在这个问题中是至关重要的。搜索谷歌只给了我类本身的链接,旧文章,或者完全不相关的文章。我得到的最接近的是JSONArray和JSONObject,这是一个

  • 我想对包含来自另一个代码VBA的消息框的行进行注释。我正在用库VBA扩展性尝试这一点,但我没有找到解决方案。 欢迎任何帮助。 这是我的代码: