alpha

How to set the opacity/alpha of a UIImage?

為{幸葍}努か 提交于 2019-11-26 06:19:26
问题 I know you can do this with a UIImageView, but can it be done to a UIImage? I want to have the animation images array property of a UIImageView to be an array of the same image but with different opacities. Thoughts? 回答1: I just needed to do this, but thought Steven's solution would be slow. This should hopefully use graphics HW. Create a category on UIImage: - (UIImage *)imageByApplyingAlpha:(CGFloat) alpha { UIGraphicsBeginImageContextWithOptions(self.size, NO, 0.0f); CGContextRef ctx =

How to change a bitmap's opacity?

一世执手 提交于 2019-11-26 04:47:38
问题 I have a bitmap: Bitmap bitmap = BitmapFactory.decodeFile(\"some/arbitrary/path/image.jpg\"); But I\'m not going to display the image to the user. I want the alpha to be 100 (out of 255). If this is not possible, can I set the opacity of the Bitmap ? 回答1: You could also try BitmapDrawable instead of Bitmap . If this is useful for you depends on the way you use the bitmap... Edit As a commenter asked how he can store the bitmap with alpha, here is some code: // lets create a new empty bitmap

Merging two images

北慕城南 提交于 2019-11-26 04:05:43
问题 I need to merge two images (BufferedImage) in Java. It wouldn\'t be a problem if there was no transparency. The base image already has some transparency. I want to keep this as it is and apply a \"mask\" to it, the second image. This second image has no opaque pixels, in fact it\'s almost completely transparent, just has some less transparent pixels to give some sort of \"light effect\", like a reflex. Important detail: I don\'t want to do this on screen, with graphics, I need to obtain a

Can PNG image transparency be preserved when using PHP's GDlib imagecopyresampled?

人走茶凉 提交于 2019-11-26 00:48:01
问题 The following PHP code snippet uses GD to resize a browser-uploaded PNG to 128x128. It works great, except that the transparent areas in the original image are being replaced with a solid color- black in my case. Even though imagesavealpha is set, something isn\'t quite right. What\'s the best way to preserve the transparency in the resampled image? $uploadTempFile = $myField[ \'tmp_name\' ] list( $uploadWidth, $uploadHeight, $uploadType ) = getimagesize( $uploadTempFile ); $srcImage =

Can PNG image transparency be preserved when using PHP's GDlib imagecopyresampled?

懵懂的女人 提交于 2019-11-25 19:18:25
The following PHP code snippet uses GD to resize a browser-uploaded PNG to 128x128. It works great, except that the transparent areas in the original image are being replaced with a solid color- black in my case. Even though imagesavealpha is set, something isn't quite right. What's the best way to preserve the transparency in the resampled image? $uploadTempFile = $myField[ 'tmp_name' ] list( $uploadWidth, $uploadHeight, $uploadType ) = getimagesize( $uploadTempFile ); $srcImage = imagecreatefrompng( $uploadTempFile ); imagesavealpha( $targetImage, true ); $targetImage = imagecreatetruecolor(