Vishal Gupta Posted June 29, 2016 Share Posted June 29, 2016 How to make jpeg transparent(i think it can be done with bitmap data but how)? In the attached image i just need a clock image without black background the process i am thinking is make the second frame jpeg bitmap transparent and mask the first frame. Link to comment Share on other sites More sharing options...
mattstyles Posted June 29, 2016 Share Posted June 29, 2016 No need to fuss with bitmap masks, jpeg does not support transparency so switch to a format that does, change it to a png and it'll all work Vishal Gupta 1 Link to comment Share on other sites More sharing options...
JakeCake Posted June 29, 2016 Share Posted June 29, 2016 I agree with matt; transparency in png is a built in mask, so why overcomplicate? If you like the compression-rate of jpeg over png I suggest you take a look at some good png-compression like on https://tinypng.com/ You can get just as good results with png compression as jpeg. EDIT: I myself use a gulp task to take my loseless PNG-files and combine them into texture atlases and then pipe them into a compression task using gulp-pngquant. So I am always working with uncompressed png-files, but the final build will be compressed based on settings I can always change for quality over size. For my next project I might even move to working purely with photoshop files and have a task to convert my photoshop files into pngs. mattstyles, Vishal Gupta, Alexalten and 1 other 4 Link to comment Share on other sites More sharing options...
Vishal Gupta Posted June 29, 2016 Author Share Posted June 29, 2016 7 hours ago, JakeCake said: I agree with matt; transparency in png is a built in mask, so why overcomplicate? If you like the compression-rate of jpeg over png I suggest you take a look at some good png-compression like on https://tinypng.com/ You can get just as good results with png compression as jpeg. EDIT: I myself use a gulp task to take my loseless PNG-files and combine them into texture atlases and then pipe them into a compression task using gulp-pngquant. So I am always working with uncompressed png-files, but the final build will be compressed based on settings I can always change for quality over size. For my next project I might even move to working purely with photoshop files and have a task to convert my photoshop files into pngs. Thanks for the reply and the way you guys suggests. although i am able to do this thing by using Phaser Bitmap data. by using replaceRGB with changing black or white color to any color with alpha 0. var sprite = new Phaser.Image(game,0,0,'clock',1); var sprite2 = new Phaser.Image(game,0,0,'clock',0); var bmd = game.make.bitmapData(53,40); bmd.load(sprite); bmd.replaceRGB(0, 0, 0, 255, 0, 0, 0, 0); var bmd1 = game.make.bitmapData(53,40); bmd1.alphaMask(sprite2,bmd); game.add.image(400, 0, bmd1); Alexalten 1 Link to comment Share on other sites More sharing options...
mattstyles Posted June 30, 2016 Share Posted June 30, 2016 Yep, that'll work, its just slow as you're doing a lot of work, and its done in the JS thread, but, you're only doing it once so its up to you how important performance is. Link to comment Share on other sites More sharing options...
Recommended Posts