本文整理汇总了Java中net.rim.device.api.system.Bitmap类的典型用法代码示例。如果您正苦于以下问题:Java Bitmap类的具体用法?Java Bitmap怎么用?Java Bitmap使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Bitmap类属于net.rim.device.api.system包,在下文中一共展示了Bitmap类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: sublayout
import net.rim.device.api.system.Bitmap; //导入依赖的package包/类
public void sublayout(int w, int h) {
//super.sublayout(w, h);
// the alternative undeprecated API requires a signature
if(net.rim.device.api.ui.Graphics.getScreenWidth() != screenWidth ||
net.rim.device.api.ui.Graphics.getScreenHeight() != screenHeight) {
screenWidth = net.rim.device.api.ui.Graphics.getScreenWidth();
screenHeight = net.rim.device.api.ui.Graphics.getScreenHeight();
if(screenWidth > 0 && screenHeight > 0) {
screen = new Bitmap(screenWidth, screenHeight);
globalGraphics = new Graphics(screen);
if(impl != null) {
impl.sizeChanged(screenWidth, screenHeight);
}
}
}
super.sublayout(w, h);
}
示例2: scale
import net.rim.device.api.system.Bitmap; //导入依赖的package包/类
/**
* @inheritDoc
*/
public Object scale(Object nativeImage, int width, int height) {
Bitmap image = (Bitmap) nativeImage;
int srcWidth = image.getWidth();
int srcHeight = image.getHeight();
// no need to scale
if (srcWidth == width && srcHeight == height) {
return image;
}
int[] currentArray = new int[srcWidth];
int[] destinationArray = new int[width * height];
scaleArray(image, srcWidth, srcHeight, height, width, currentArray, destinationArray);
return createImage(destinationArray, width, height);
}
示例3: scaleArray
import net.rim.device.api.system.Bitmap; //导入依赖的package包/类
private void scaleArray(Bitmap currentImage, int srcWidth, int srcHeight, int height, int width, int[] currentArray, int[] destinationArray) {
// Horizontal Resize
int yRatio = (srcHeight << 16) / height;
int xRatio = (srcWidth << 16) / width;
int xPos = xRatio / 2;
int yPos = yRatio / 2;
// if there is more than 16bit color there is no point in using mutable
// images since they won't save any memory
for (int y = 0; y < height; y++) {
int srcY = yPos >> 16;
getRGB(currentImage, currentArray, 0, 0, srcY, srcWidth, 1);
for (int x = 0; x < width; x++) {
int srcX = xPos >> 16;
int destPixel = x + y * width;
if ((destPixel >= 0 && destPixel < destinationArray.length) && (srcX < currentArray.length)) {
destinationArray[destPixel] = currentArray[srcX];
}
xPos += xRatio;
}
yPos += yRatio;
xPos = xRatio / 2;
}
}
示例4: BitmapLuminanceSource
import net.rim.device.api.system.Bitmap; //导入依赖的package包/类
/**
* Construct luminance source for specified Bitmap
* @param bitmap
*/
public BitmapLuminanceSource(Bitmap bitmap) {
super(bitmap.getWidth(), bitmap.getHeight());
int width = bitmap.getWidth();
int height = bitmap.getHeight();
_bitmap = bitmap;
int area = width * height;
_matrix = new byte[area];
int[] rgb = new int[area];
_bitmap.getARGB(rgb, 0, width, 0, 0, width, height);
for (int y = 0; y < height; y++) {
int offset = y * width;
for (int x = 0; x < width; x++) {
int pixel = rgb[offset + x];
int luminance = (306 * ((pixel >> 16) & 0xFF) + 601
* ((pixel >> 8) & 0xFF) + 117 * (pixel & 0xFF)) >> 10;
_matrix[offset + x] = (byte) luminance;
}
}
rgb = null;
}
示例5: FileItem
import net.rim.device.api.system.Bitmap; //导入依赖的package包/类
public FileItem(FileSystemObject fso) {
this.fso = fso;
Pair bitmaps = fetchBitmaps(fso);
bitmapNormal = (Bitmap) bitmaps.first;
bitmapHover = (Bitmap) bitmaps.second;
label = new CustomLabelField(
(fso == null) ? tr(VikaResource.Back) : fso.displayName,
DrawStyle.ELLIPSIS | Field.FIELD_VCENTER, THEME);
icon = new ImageField(bitmapNormal, DP12, DP12, Field.FIELD_VCENTER, false);
HorizontalFieldManager hfm = new HorizontalFieldManager();
hfm.add(icon);
hfm.add(label);
add(hfm);
addingCompleted();
}
示例6: drawPixels
import net.rim.device.api.system.Bitmap; //导入依赖的package包/类
private static void drawPixels(Bitmap src, int[][] m, int destX, int destY) {
int[] data = new int[m.length * m.length];
src.getARGB(data, 0, m.length, destX, destY, m.length, m.length);
for (int y = destY; y < destY + m.length; ++y) {
for (int x = destX; x < destX + m[y - destY].length; ++x) {
int pos = m.length * (y - destY) + x - destX;
int b = data[pos] % RoundAngles.E1;
int g = (data[pos] - b) / 256 % RoundAngles.E1;
int r = (data[pos] - b - RoundAngles.E1 * g) / RoundAngles.E2 % RoundAngles.E1;
data[pos] = m[y - destY][x - destX] * RoundAngles.E3 + b + g * RoundAngles.E1 + r
* RoundAngles.E2;
}
}
src.setARGB(data, 0, m.length, destX, destY, m.length, m.length);
}
示例7: roundAngles
import net.rim.device.api.system.Bitmap; //导入依赖的package包/类
public static void roundAngles(Bitmap src, int radius) {
if (radius < 2) {
radius = 2;
}
if (radius > maps.length) {
radius = maps.length;
}
int[][] m0 = RoundAngles.maps[radius];
int[][] m1 = RoundAngles.swapHorizontal(RoundAngles.maps[radius]);
int[][] m2 = RoundAngles.swapVertical(RoundAngles.maps[radius]);
int[][] m3 = RoundAngles.swapHorizontal(m2);
RoundAngles.drawPixels(src, m0, 0, 0);
RoundAngles.drawPixels(src, m1, src.getWidth() - radius, 0);
RoundAngles.drawPixels(src, m2, 0, src.getHeight() - radius);
RoundAngles.drawPixels(src, m3, src.getWidth() - radius, src.getHeight() - radius);
}
示例8: AbstractBitmapField
import net.rim.device.api.system.Bitmap; //导入依赖的package包/类
public AbstractBitmapField(Bitmap bmp, XYDimension size, boolean scale,
boolean roundAngles) {
int newHeight = size.height, newWidth = size.width;
Bitmap newBmp;
if (bmp.getWidth() > newWidth || bmp.getHeight() > newHeight || scale) {
newBmp = GPATools.ResizeTransparentBitmap(bmp, newWidth, newHeight,
Bitmap.FILTER_LANCZOS, Bitmap.SCALE_TO_FIT);
} else {
newBmp = bmp;
}
this.height = newHeight;
this.width = newWidth;
if (roundAngles) {
RoundAngles.roundAngles(newBmp, 3);
}
this.bmp = newBmp;
}
示例9: ImageSelectorField
import net.rim.device.api.system.Bitmap; //导入依赖的package包/类
public ImageSelectorField(Bitmap defaultBmp, Bitmap focusBmp, Bitmap activeBmp,
Bitmap selectedBmp,
int width, int height, long style, Theme theme, boolean scale) {
super(style, theme);
this.scale = scale;
XYEdges padding = theme.getPaddingEdges();
fullWidth = width;
imageWidth = fullWidth - padding.left - padding.right;
fullHeight = height;
imageHeight = fullHeight - padding.top - padding.bottom;
XYDimension dim = new XYDimension(imageWidth, imageHeight);
this.defaultBmp = new AbstractBitmapField(defaultBmp, dim, scale);
this.focusBmp = new AbstractBitmapField(focusBmp, dim, scale);
this.activeBmp = new AbstractBitmapField(activeBmp, dim, scale);
if (activeBmp != selectedBmp) {
this.selectedBmp = new AbstractBitmapField(selectedBmp, dim, scale);
} else {
this.selectedBmp = this.activeBmp;
}
}
示例10: CompoundButtonField
import net.rim.device.api.system.Bitmap; //导入依赖的package包/类
public CompoundButtonField(String text, Bitmap b) {
super(0, CompoundButtonField.THEME);
VerticalFieldManager vfm = new VerticalFieldManager();
vfm.setPadding(DP2, DP2, DP2, DP2);
BitmapField bitmap = new BitmapField(b, Field.FIELD_HCENTER);
vfm.add(bitmap);
String[] lines = StringUtils.split(text, "\n");
for (int i = 0; i < lines.length; ++i) {
CustomLabelField label = new CustomLabelField(lines[i],
DrawStyle.HCENTER | Field.FIELD_HCENTER,
CompoundButtonField.LABEL_THEME);
vfm.add(label);
}
add(vfm);
addingCompleted();
}
示例11: DisplayStory
import net.rim.device.api.system.Bitmap; //导入依赖的package包/类
DisplayStory(EncodedImage original, Bitmap img, UiApplication app, int time) {
_original = original;
int direction = Display.DIRECTION_NORTH;
Ui.getUiEngineInstance().setAcceptableDirections(direction);
monApp = app;
_img = img;
//this.setTitle(Caption);
this.addMenuItem(_ScreenShootitem);
this.addMenuItem(_Nextstoryitem);
this.addMenuItem(_EndStoryitem);
// afficher l'image.
HorizontalFieldManager SnapManager = new HorizontalFieldManager();
bmp = new BitmapField();
SnapManager.add(bmp);
this.add(SnapManager);
t = new Timer();
t.schedule(new Chronometer(time, img), 0, 1000);
}
示例12: run
import net.rim.device.api.system.Bitmap; //导入依赖的package包/类
public void run() {
synchronized (UiApplication.getEventLock()) {
if (_time > 0) {
Bitmap _bmp = new Bitmap(Display.getWidth(),
Display.getHeight());
Graphics g = new Graphics(_bmp);
g.setColor(Color.BLACK);
g.fillRect(0, 0, Display.getWidth(), Display.getHeight());
g.drawBitmap(
((_bmp.getWidth() / 2) - (_img.getWidth() / 2)), 0,
_img.getWidth(), _img.getHeight(), _img, 0, 0);
g.setColor(Color.WHITE);
g.drawText(_time + "s", Display.getWidth() - 60,
Display.getHeight() - 50);
bmp.setBitmap(_bmp);
_time--;
} else {
t.cancel();
quit();
}
}
}
示例13: DisplaySnap
import net.rim.device.api.system.Bitmap; //导入依赖的package包/类
DisplaySnap(EncodedImage original, Bitmap img, int time, UiApplication app, JSONObject Current, String key) {
_original = original;
int direction = Display.DIRECTION_NORTH;
Ui.getUiEngineInstance().setAcceptableDirections(direction);
monApp = app;
_img = img;
_Current = Current;
_key = key;
// afficher l'image.
this.addMenuItem(_ScreenShootitem);
HorizontalFieldManager SnapManager = new HorizontalFieldManager();
bmp = new BitmapField();
SnapManager.add(bmp);
this.add(SnapManager);
t = new Timer();
t.schedule(new Chronometer(time, img), 0, 1000);
}
示例14: run
import net.rim.device.api.system.Bitmap; //导入依赖的package包/类
public void run() {
synchronized (UiApplication.getEventLock()) {
if (_time > 0) {
Bitmap _bmp = new Bitmap(Display.getWidth(),
Display.getHeight());
Graphics g = new Graphics(_bmp);
g.setColor(Color.BLACK);
g.fillRect(0, 0, Display.getWidth(), Display.getHeight());
g.drawBitmap(
((_bmp.getWidth() / 2) - (_img.getWidth() / 2)), 0,
_img.getWidth(), _img.getHeight(), _img, 0, 0);
g.setColor(Color.WHITE);
g.drawText(_time + "s", Display.getWidth() - 60,
Display.getHeight() - 50);
bmp.setBitmap(_bmp);
_time--;
} else {
t.cancel();
quit();
}
}
}
示例15: ViewStory
import net.rim.device.api.system.Bitmap; //导入依赖的package包/类
ViewStory(JSONObject Current, UiApplication monApp) {
int direction = Display.DIRECTION_NORTH;
Ui.getUiEngineInstance().setAcceptableDirections(direction);
_monApp = monApp;
_Current = Current;
this.setTitle(" CrapSnap - View Stories");
Bitmap back = EncodedImage.getEncodedImageResource("snapBack.png")
.getBitmap();
this.setBackground(BackgroundFactory.createBitmapBackground(back));
// {
// username: "youraccount",
// timestamp: 1373207221,
// req_token: create_token(auth_token, 1373207221)
// }
populate();
}