六狼论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博账号登陆

只需一步,快速开始

搜索
查看: 60|回复: 0

Fade in and out images in MIDP 2.0

[复制链接]

升级  28.67%

27

主题

27

主题

27

主题

秀才

Rank: 2

积分
93
 楼主| 发表于 2013-1-27 04:43:20 | 显示全部楼层 |阅读模式
This tip describes how to change the alpha value of an image to make itappear blended. There's also an example MIDlet with source code.

In MIDP 2.0 there's a new method in the Image class, getRGB(...)that will get all Alpha, Red, Green, Blue (ARGB) values from the imageto an int array. We can use this method, and the resulting array, tochange the alpha value of the image.

Integers in J2ME are four bytes, each pixel in the image is describedby the ARGB values where each color is one byte 0 to 255. If the alphavalue is 0, the corresponding pixel will be transparent, if the alphais 255, the pixel will be opaque.

To get a specific color from the int array, it's possible to use the AND '&' operator and to accomplish the blending effect we need to get the colors, without the alpha value, from the int array.
<div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!---->FF = 11111111 = 255
0xFFFFFFFF - Alpha = 255, Red =255 Green = 255, Blue = 255
(
0xFFFFFFFF & 0x00FFFFFF= 0x00FFFFFF

您需要登录后才可以回帖 登录 | 立即注册 新浪微博账号登陆

本版积分规则

快速回复 返回顶部 返回列表