Blackberry JAVA DEVELOPMENT ENVIRONMENT - - CRYPTOGRAPHIC SMART CARD DRIVER - DEVELOPMENT GUIDE Průvodce řešením problémů Strana 47

  • Stažení
  • Přidat do mých příruček
  • Tisk
  • Strana
    / 286
  • Tabulka s obsahem
  • KNIHY
  • Hodnocené. / 5. Na základě hodnocení zákazníků
Zobrazit stránku 46
47
2: Using graphics and multimedia
Code sample: Using a raw image to recreate an encoded image
Example: ImageDemo.java
/**
* ImageDemo.java
* Copyright (C) 2001-2005 Research In Motion Limited. All rights reserved.
*/
package com.rim.samples.docs.imagedemo;
import net.rim.device.api.ui.*;
import net.rim.device.api.ui.component.*;
import net.rim.device.api.ui.container.*;
import net.rim.device.api.system.*;
import java.io.*;
/* The ImageDemo.java sample retrieves raw data from an image that
is included in its project, and then uses that raw data to
recreate an EncodedImage. */
public class ImageDemo extends UiApplication {
public static void main(String[] args) {
ImageDemo app = new ImageDemo();
app.enterEventDispatcher();
}
public ImageDemo() {
pushScreen(new ImageDemoScreen());
}
}
final class ImageDemoScreen extends MainScreen {
private static final int IMAGE_SIZE = 2430;
private InputStream input;
private byte[] data = new byte[IMAGE_SIZE];
public ImageDemoScreen() {
super();
setTitle(new LabelField(“Image Demo Sample”));
try {
input =
Class.forName(“com.rim.samples.docs.imagedemo.ImageDemo”).getResourceAsStream(“/images/
hellokitty.png”);
} catch (ClassNotFoundException e) {
System.out.println(“Class not found”);
}
if(input == null) {
System.out.println(“Error: input stream is not initialized.”);
} else if (input != null) {
System.out.println(“OK: input stream is initialized.”);
try {
int code = input.read(data);
System.out.println(“Total number of bytes read into buffer: “ + code + “
.”);
} catch (IOException e) {
// Handle exception.
}
Zobrazit stránku 46
1 2 ... 42 43 44 45 46 47 48 49 50 51 52 ... 285 286

Komentáře k této Příručce

Žádné komentáře