Public static void main (string [] ARGs) {<br/> try {<br/> bufferedimage image = ImageIO <br/>. read (New fileinputstream ("F: // 1.jpg"); <br/> // read the icon <br/> bufferedimage imagebiao = ImageIO. read (New fileinputstream (<br/> "F: // 3.png"); <br/> graphics2d G = image. creategraphics (); <br/> // G. setcolor (color. yellow); <br/> // G. setfont (new font (" 文中", Font. layout_left_to_right, 48); <br/> // G. draw String ("image synthesis example", 100, image. getheight ()-400); <br/> // write icon <br/> imagefilter imgf = new myfilter (255 ); <br/> filteredimagesource FD = new filteredimagesource (imagebiao <br/>. getsource (), imgf); <br/> image im = toolkit. getdefatooltoolkit (). createimage (FCM); <br/> G. drawimage (IM, 0, 0, imagebiao. getwidth (null), imagebiao <br/>. getheight (null), null); <br/> G. dispose (); <br/> fileoutputstream ou T = new fileoutputstream ("F: // graphic character synthesis 3.gif"); <br/> required imageencoder encoder = required codec. createjpegencoder (out); <br/> encoder. encode (image); <br/> out. close (); <br/> // Add the above source image and the added image <br/>} catch (exception e) {<br/> E. printstacktrace (); <br/>}< br/> class myfilter extends rgbimagefilter {// abstract class rgbimagefilter is a subclass of imagefilter, <br/> // inherit it to process the image argb <br/> int alpha = 0; <br/> Public my Filter (INT alpha) {// constructor, used to receive the size and transparency of the image to be filtered <br/> This. canfilterindexcolormodel = true; <br/> // The transparentimagefilter class inherits from rgbimagefilter. Its constructor requires passing in the width and height of the original image. <Br/> // This class implements the filterrgb abstract function <br/> //. By default, this function transfers the argb value of the pixel identified by X and Y, after processing according to a certain program logic, the programmer returns the new argb value of the pixel. <br/> This. alpha = Alpha; <br/>}< br/> Public int filterrgb (int x, int y, int RGB) {<br/> directcolormodel DCM = (directcolormodel) colormodel. getrgbdefault (); <br/> // The directcolormodel class is used to separate the argb values. <br/> int Red = DCM. getred (RGB); <br/> int Green = DCM. getgreen (RGB); <br/> int Blue = DCM. getblue (RGB); <br/> int phosphatase = DCM. getalpha (RGB); <br/> If (Red = 255 & Blue = 255 & green = 255) {// If the pixel is white, make it transparent <br/> alpha = 0; <br/>}else {<br/> alpha = 255; <br/>}< br/> // If (alkaline = 0) {// the transparent part of images in PNG and GIF formats is still transparent <br/> // alpha = 0; <br/> //} else {<br/> // alpha = 255; <br/> //} <br/> return Alpha <24 | red <16 | green <8 | blue; // perform standard argb output for image filtering <br/>}< br/> if so, the effect can be achieved, however, the white image is distorted when it is replaced by other colors. <br/> after finding some PNG and GIF images, the white ones are removed, think you can directly synthesize it, but not, but you need to add the Alpha judgment <br/> // If (BMP = 0) {// the transparency of images in PNG and GIF formats is still transparent <br/> // alpha = 0; <br/> //} else {<br/> // alpha = 255; <br/>//} <br/> however, the effect is still poor, however, it is much better to make the image more transparent than the previous one, so we need to process the image first and then call the Program <br/> these are all transparent parts of the image. If we want to make all the parts transparent together, we recommend that you use the getinstance (INT rule, float alpha) method of the alphacomposite class to set the Alpha value </P> <p> Source: http://hi.baidu.com/berry_0712/blog/item/6a28190f7ce02c2d6059f3e2.html <br/>