我想將一些圖像加載到雲中,但是當有人查看照片並保存圖像時,我想添加一些保護措施;由於透明度,他們不會看到任何東西。是否可以在Java和Android中爲jpg添加透明度
該代碼對Java和Android通用?我想首先用Java對它進行原型設計。
我發現一些結合了兩個文件的代碼。一個文件是我的主文件,另一個文件是透明文件。組合文件沒有透明覆蓋圖。
BufferedImage image = ImageIO.read(new File("rose.jpg"));
BufferedImage overlay = ImageIO.read(new File("myimg1.gif"));
// create the new image, canvas size is the max. of both image sizes
int w = Math.max(image.getWidth(), overlay.getWidth());
int h = Math.max(image.getHeight(), overlay.getHeight());
BufferedImage combined = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB);
// paint both images, preserving the alpha channels
Graphics g = combined.getGraphics();
g.drawImage(image, 0, 0, null);
g.drawImage(overlay, 0, 0, null);
// Save as new image
ImageIO.write(combined, "PNG", new File("combined.png"));
添加代碼來合併兩張照片,但是,是否有人知道如何將透明圖像放在主圖像上。我有什麼不起作用。我希望當用戶在網絡上看到照片,然後試圖做一個「另存爲」他們保存的圖像將是透明的,圖像對他們來說是無用的。這將主要針對Android應用程序。我可以禁用瀏覽器中的保存和複製功能是另一個想法嗎? – user1024882