精华内容
下载资源
问答
  • 本文整理匯總了Java中javax.microedition.lcdui.Image.createImage方法的典型用法代碼示例。如果您正苦於以下問題:Java Image.createImage方法的具體用法?Java Image.createImage怎麽用?Java Image.createImage...

    本文整理匯總了Java中javax.microedition.lcdui.Image.createImage方法的典型用法代碼示例。如果您正苦於以下問題:Java Image.createImage方法的具體用法?Java Image.createImage怎麽用?Java Image.createImage使用的例子?那麽恭喜您, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.microedition.lcdui.Image的用法示例。

    在下文中一共展示了Image.createImage方法的24個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於我們的係統推薦出更棒的Java代碼示例。

    示例1: getListRowImage

    ​點讚 3

    import javax.microedition.lcdui.Image; //導入方法依賴的package包/類

    private Image getListRowImage(int priority){

    Image image = null;

    String path;

    if (priority < 3)

    path = "/low.png";

    else if (priority < 7)

    path = "/normal.png";

    else

    path = "/important.png";

    try {

    image = Image.createImage(path);

    } catch (IOException e) {

    e.printStackTrace();

    }

    return image;

    }

    開發者ID:NotesTeam,項目名稱:TaskBook-J2ME,代碼行數:18,

    示例2: getCategoryImage

    ​點讚 3

    import javax.microedition.lcdui.Image; //導入方法依賴的package包/類

    private Image getCategoryImage(String id) {

    Image image = null;

    String path;

    if(id.equals("Family"))

    path = "/family.png";

    else if(id.equals("Work"))

    path = "/work.png";

    else

    path = "/school.png";

    try {

    image = Image.createImage(path);

    } catch (IOException e) {

    e.printStackTrace();

    }

    return image;

    }

    開發者ID:NotesTeam,項目名稱:TaskBook-J2ME,代碼行數:19,

    示例3: init

    ​點讚 3

    import javax.microedition.lcdui.Image; //導入方法依賴的package包/類

    /**

    * ���������ʼ��

    * @param score ����

    * @throws IOException

    */

    public void init(int score) throws IOException

    {

    /*��Ϸ����:42,23

    gameover:42,38

    ������:38,58

    ����ͼƬ:45,107*/

    gameovertip=Image.createImage("/gameovertip.GIF");

    endtip=Image.createImage("/endtip.GIF");

    scorebg=Image.createImage("/scorebg.GIF");

    gameoverbg=Image.createImage("/gameoverbg.GIF");

    Graphics gra=super.getGraphics();

    gra.setColor(255, 255, 255);

    gra.fillRect(0, 0, sw, sh);

    gra.drawImage(endtip, 42, 23,Graphics.LEFT|Graphics.TOP);

    gra.drawImage(gameovertip, 42, 38,Graphics.LEFT|Graphics.TOP);

    gra.drawImage(scorebg, 38, 58,Graphics.LEFT|Graphics.TOP);

    gra.drawImage(gameoverbg, 45, 107,Graphics.LEFT|Graphics.TOP);

    flushGraphics();

    repaint();

    super.ShowScore(score);

    System.out.println("��������������");

    }

    開發者ID:cabbage89,項目名稱:danceGame,代碼行數:29,

    示例4: PaintCanvas

    ​點讚 3

    import javax.microedition.lcdui.Image; //導入方法依賴的package包/類

    public PaintCanvas(ApplicationListener listener, boolean isLandscape) {

    this.listener = listener;

    this.isLandscape = isLandscape;

    setFullScreenMode(true);

    width = getWidth();

    height = getHeight();

    if (isLandscape) {

    width = height;

    height = getWidth();

    }

    image = Image.createImage(width, height);

    Graphics g = image.getGraphics();

    graphics = new JecpGraphics(g);

    listener.onStartApp(width, height);

    thread = new DrawingThread();

    thread.keepRunning = true;

    thread.start();

    }

    開發者ID:aNNiMON,項目名稱:JECP,代碼行數:21,

    示例5: GameCanvasLFImpl

    ​點讚 3

    import javax.microedition.lcdui.Image; //導入方法依賴的package包/類

    /**

    * Create new implementation instance for the given GameCanvas

    * @param c GameCanvas instance to create the implementation for

    */

    public GameCanvasLFImpl(GameCanvas c) {

    owner = c;

    graphicsAccess = GameMap.getGraphicsAccess();

    /* IMPL_NOTE: The initial off-screen buffer has the same width

    * and height as the entire screen. Further resizing will not

    * cause memory reallocation until new geometry is bigger than

    * the current one. Screen rotation is one of the cases the

    * reallocation is needed.

    *

    * User can override the methods getWidth() and getHeight() of

    * GameCanvas, so they should not be used for off-screen buffer

    * initial allocation.

    */

    offscreenBuffer = Image.createImage(

    graphicsAccess.getScreenWidth(),

    graphicsAccess.getScreenHeight());

    }

    開發者ID:mozilla,項目名稱:pluotsorbet,代碼行數:24,

    示例6: Screen

    ​點讚 3

    import javax.microedition.lcdui.Image; //導入方法依賴的package包/類

    public Screen(Display display) {

    super();

    this.setFullScreenMode(true);

    this.parentDisplay = display;

    updateOrientation();

    try {

    // Create background image

    this.background = Image.createImage("midlets/blogwriter/images/Background.png");

    } catch (IOException e) {

    this.parentDisplay.setCurrent(

    new Alert("Cannot create graphics."), this);

    }

    VirtualKeyboard.setVisibilityListener(this);

    }

    開發者ID:mozilla,項目名稱:pluotsorbet,代碼行數:17,

    示例7: MyCanvas

    ​點讚 2

    import javax.microedition.lcdui.Image; //導入方法依賴的package包/類

    protected MyCanvas(boolean suppressKeyEvents,boolean hasreadhistory) {

    super(suppressKeyEvents);

    // TODO Auto-generated constructor stub

    try {

    bg=Image.createImage("/bg.GIF");

    oready=Image.createImage("/oready.GIF");

    o1=Image.createImage("/o1.GIF");

    o3=Image.createImage("/o3.GIF");

    o7=Image.createImage("/o7.GIF");

    o9=Image.createImage("/o9.GIF");

    lift=Image.createImage("/lift.GIF");

    liftbg=Image.createImage("/liftbg.GIF");

    pass=Image.createImage("/pass.GIF");

    notpass=Image.createImage("/notpass.GIF");

    passbg=Image.createImage("/passbg.GIF");

    passarea=Image.createImage("/passarea.GIF");

    scorearea=Image.createImage("/scorearea.GIF");

    n0=Image.createImage("/0.GIF");

    n1=Image.createImage("/1.GIF");

    n2=Image.createImage("/2.GIF");

    n3=Image.createImage("/3.GIF");

    n4=Image.createImage("/4.GIF");

    n5=Image.createImage("/5.GIF");

    n6=Image.createImage("/6.GIF");

    n7=Image.createImage("/7.GIF");

    n8=Image.createImage("/8.GIF");

    n9=Image.createImage("/9.GIF");

    ispass=getClass().getResourceAsStream("/pass.wav");

    System.out.println("ͼƬ��������ʼ�����...");

    } catch (IOException e) {

    // TODO Auto-generated catch block

    e.printStackTrace();

    System.out.println("��ȡͼƬ�쳣");

    }

    init(hasreadhistory);//��ʼ����Ϸ����

    }

    開發者ID:cabbage89,項目名稱:danceGame,代碼行數:40,

    示例8: MyCanvas

    ​點讚 2

    import javax.microedition.lcdui.Image; //導入方法依賴的package包/類

    protected MyCanvas(boolean suppressKeyEvents) {

    super(suppressKeyEvents);

    // TODO Auto-generated constructor stub

    try {

    bg=Image.createImage("/bg.GIF");

    oready=Image.createImage("/oready.GIF");

    o1=Image.createImage("/o1.GIF");

    o3=Image.createImage("/o3.GIF");

    o7=Image.createImage("/o7.GIF");

    o9=Image.createImage("/o9.GIF");

    lift=Image.createImage("/lift.GIF");

    liftbg=Image.createImage("/liftbg.GIF");

    pass=Image.createImage("/pass.GIF");

    notpass=Image.createImage("/notpass.GIF");

    passbg=Image.createImage("/passbg.GIF");

    passarea=Image.createImage("/passarea.GIF");

    scorearea=Image.createImage("/scorearea.GIF");

    n0=Image.createImage("/0.GIF");

    n1=Image.createImage("/1.GIF");

    n2=Image.createImage("/2.GIF");

    n3=Image.createImage("/3.GIF");

    n4=Image.createImage("/4.GIF");

    n5=Image.createImage("/5.GIF");

    n6=Image.createImage("/6.GIF");

    n7=Image.createImage("/7.GIF");

    n8=Image.createImage("/8.GIF");

    n9=Image.createImage("/9.GIF");

    } catch (IOException e) {

    // TODO Auto-generated catch block

    e.printStackTrace();

    System.out.println("��ȡͼƬ�쳣");

    }

    init();//��ʼ����Ϸ����

    }

    開發者ID:cabbage89,項目名稱:danceGame,代碼行數:36,

    示例9: createImages

    ​點讚 2

    import javax.microedition.lcdui.Image; //導入方法依賴的package包/類

    public void createImages()

    {

    try

    {

    active = Image.createImage("/images/button_in(red).png");

    inactive = Image.createImage("/images/button(red).png");

    overin = Image.createImage("/images/button_in_over(red).png");

    overout = Image.createImage("/images/button_over(red).png");

    }

    catch (IOException e) {

    System.out.println("Images not found");

    }

    }

    開發者ID:WernerLDev,項目名稱:Beatmaker,代碼行數:14,

    示例10: getImageItemForScreen

    ​點讚 2

    import javax.microedition.lcdui.Image; //導入方法依賴的package包/類

    protected ImageItem getImageItemForScreen(InputStream is) {

    Image im = null;

    try {

    im = Image.createImage(is);

    } catch(OutOfMemoryError ome ){

    ome.printStackTrace();

    Logger.die("GetImageOOM", new RuntimeException(ome.getMessage()));

    return null;

    } catch (IOException e) {

    // TODO Auto-generated catch block

    e.printStackTrace();

    Logger.die("GetImageioe", e);

    }

    if(im !=null){

    Logger.log("file", "got an image");

    int height = scrHeight/2;

    int width = scrWidth-16;

    //scale

    int[] newDimension = ImageUtils.getNewDimensions(im, height, width);

    if(newDimension[0] != height || newDimension[1] != width) {

    im = ImageUtils.resizeImage(im, newDimension[1], newDimension[0]);

    }

    Logger.log("file", "resized it");

    ImageItem imItem = new ImageItem(null,im, ImageItem.LAYOUT_CENTER | ImageItem.LAYOUT_VCENTER, "Cannot Display Image");

    imItem.setLayout(Item.LAYOUT_CENTER);

    return imItem;

    }else{

    return null;

    }

    }

    開發者ID:dimagi,項目名稱:commcare-j2me,代碼行數:34,

    示例11: start

    ​點讚 2

    import javax.microedition.lcdui.Image; //導入方法依賴的package包/類

    public synchronized void start()

    {

    //Afbeeldingen maken voor de achtergrond en het pijltje wat aangeeft op welke positie

    //de beatmaker is

    try

    {

    positie = Image.createImage("/images/pijl.png");

    bgimage = Image.createImage("/background.jpg");

    }

    catch (IOException e) {

    System.out.println("Images not found");

    }

    //Knoppen om van instrument te wissen aanmaken

    piano = new InstrumentButton(30,4, g, "piano");

    gitaar = new InstrumentButton(30,130, g, "gitaar");

    drums = new InstrumentButton(30, 260, g, "overig");

    play = new PlayKnop(g, 30, 570);

    //standaard krijg je de piano voor je neus dus deze zetten we aan

    piano.turnOn();

    //DIt is om te controlleren op welke pad we geklikt hebben

    action = new TouchActions();

    createInstruments();

    draw();

    playLoop();

    }

    開發者ID:WernerLDev,項目名稱:Beatmaker,代碼行數:30,

    示例12: start

    ​點讚 2

    import javax.microedition.lcdui.Image; //導入方法依賴的package包/類

    public void start() {

    Image image = null;

    try {

    image = Image.createImage(this.picture);

    } catch (Exception e) {

    throw new RuntimeException("Busted splash screen image. Fix this");

    }

    InitializerSplashScreen splashScreen = new InitializerSplashScreen(Display.getInstance(),

    image, backgroundColor, null, messageColor, this);

    J2MEDisplay.setView(splashScreen);

    }

    開發者ID:dimagi,項目名稱:commcare-j2me,代碼行數:13,

    示例13: ButtonState

    ​點讚 2

    import javax.microedition.lcdui.Image; //導入方法依賴的package包/類

    public ButtonState(CanvasItem owner, String image, int color)

    throws Exception {

    this.owner = owner;

    this.labelColor = color;

    try {

    this.background = Image.createImage(image);

    } catch (IOException e) {

    throw new Exception("Unable to load graphics resources.");

    }

    }

    開發者ID:mozilla,項目名稱:pluotsorbet,代碼行數:11,

    示例14: loadImage

    ​點讚 2

    import javax.microedition.lcdui.Image; //導入方法依賴的package包/類

    /**

    * Inefficient way to read the image data from the InputStream but

    * necessary for some servers.

    * @param in

    * @param out

    * @return

    * @throws IOException

    */

    private Image loadImage(InputStream in, ByteArrayOutputStream out) throws IOException {

    int b;

    while ((b = in.read()) != -1) {

    out.write(b);

    }

    byte[] buf = out.toByteArray();

    return Image.createImage(buf, 0, buf.length);

    }

    開發者ID:cli,項目名稱:worldmap-classic,代碼行數:17,

    示例15: createImage

    ​點讚 2

    import javax.microedition.lcdui.Image; //導入方法依賴的package包/類

    public static Image createImage(int width, int height, int argb) {

    // Image::createImage(int width, int height)

    // in turn calls

    // ImageDataFactory::createMutableImageData(ImageData data, int width, int height)

    Image image = Image.createImage(width, height);

    setPixels(image, argb);

    return image;

    }

    開發者ID:mozilla,項目名稱:pluotsorbet,代碼行數:9,

    示例16: readImage

    ​點讚 2

    import javax.microedition.lcdui.Image; //導入方法依賴的package包/類

    /**

    * Reads next frame image

    */

    protected void readImage() {

    ix = readShort(); // (sub)image position & size

    iy = readShort();

    iw = readShort();

    ih = readShort();

    int packed = read();

    lctFlag = (packed & 0x80) != 0; // 1 - local color table flag

    interlace = (packed & 0x40) != 0; // 2 - interlace flag

    // 3 - sort flag

    // 4-5 - reserved

    lctSize = 2 << (packed & 7); // 6-8 - local color table size

    if (lctFlag) {

    lct = readColorTable(lctSize); // read table

    act = lct; // make local table active

    } else {

    act = gct; // make global table active

    if (bgIndex == transIndex) {

    bgColor = 0;

    }

    }

    int save = 0;

    if (transparency) {

    save = act[transIndex];

    act[transIndex] = 0; // set transparent color if specified

    }

    if (act == null) {

    status = STATUS_FORMAT_ERROR; // no color table defined

    }

    if (err()) {

    return;

    }

    decodeImageData(); // decode pixel data

    skip();

    if (err()) {

    return;

    }

    frameCount++;

    // create new image to receive frame data

    image = Image.createImage(width, height);

    setPixels(); // transfer pixel data to image

    frames.addElement(new GifFrame(image, delay)); // add image to frame

    // list

    if (transparency) {

    act[transIndex] = save;

    }

    resetFrame();

    }

    開發者ID:cabbage89,項目名稱:danceGame,代碼行數:63,

    示例17: ImageME

    ​點讚 2

    import javax.microedition.lcdui.Image; //導入方法依賴的package包/類

    public ImageME(InputStream is) throws IOException {

    image = Image.createImage(is);

    if (is != null) is.close();

    }

    開發者ID:aNNiMON,項目名稱:JECP,代碼行數:5,

    示例18: populateEntries

    ​點讚 2

    import javax.microedition.lcdui.Image; //導入方法依賴的package包/類

    private void populateEntries() {

    Vector entriesVec = new Vector();

    FormIndex index = FormIndex.createBeginningOfFormIndex();

    FormDef form = model.getForm();

    int prevDepth = 0;

    while (!index.isEndOfFormIndex()) {

    if (index.isInForm() && model.isIndexRelevant(index)) {

    String text = "";

    boolean isHeader = false;

    Image img = null;

    if (model.getEvent(index) == FormEntryController.EVENT_QUESTION) {

    FormEntryPrompt prompt = model.getQuestionPrompt(index);

    text = getText(prompt);

    } else if (model.getEvent(index) == FormEntryController.EVENT_PROMPT_NEW_REPEAT) {

    FormEntryCaption[] hierachy = model.getCaptionHierarchy(index);

    text = "Add "

    + (index.getElementMultiplicity() == 0 ? "a "

    : "another ")

    + hierachy[hierachy.length - 1].getLongText() + "?";

    try {

    img = Image.createImage(Localization.get("plussign"));

    } catch (IOException ioe) {

    img = null;

    Logger.exception(ioe);

    }

    } else if ((model.getEvent(index) == FormEntryController.EVENT_GROUP)

    || (model.getEvent(index) == FormEntryController.EVENT_REPEAT)) {

    text = getHeaderText(model.getCaptionHierarchy(index));

    isHeader = true;

    }

    if (!text.equals("")) {

    Style style = isHeader ? StyleSheet

    .getStyle(Constants.STYLE_HEADER) : StyleSheet

    .getStyle(Constants.STYLE_PROMPT);

    String spacer="";

    int i = isHeader?-1:0;

    while (i < index.getDepth() - 2) {

    //ctsims : Huh?

    //spacer = "――" + spacer;

    spacer = "> > " + spacer;

    i++;

    }

    text=img==null?spacer+text:text;

    entriesVec.addElement(new Entry(text, img, style, index));

    }

    }

    prevDepth = index.getDepth();

    index = model.incrementIndex(index);

    }

    entries = new Entry[entriesVec.size()];

    entriesVec.copyInto(entries);

    }

    開發者ID:dimagi,項目名稱:commcare-j2me,代碼行數:55,

    示例19: LoginScreen

    ​點讚 2

    import javax.microedition.lcdui.Image; //導入方法依賴的package包/類

    public LoginScreen(Display display) {

    super(display);

    try {

    this.userNameTextBox = new CanvasTextBox(

    this, "Login", TextField.ANY, this.maxLoginLength);

    this.userNameTextBox.setTextEditorListener(this);

    this.passwordTextBox = new CanvasTextBox(

    this, "Password", TextField.PASSWORD, this.maxLoginLength);

    this.passwordTextBox.setTextEditorListener(this);

    } catch (IllegalStateException e1) {

    // TODO Auto-generated catch block

    this.parentDisplay.setCurrent(

    new Alert("e1 " + e1),

    this);

    //e1.printStackTrace();

    }

    //Disable Password box. It will be enabled once username is not empty.

    this.passwordTextBox.setEnabled(false);

    try {

    this.exitButton = new Button(

    this, "Exit",

    new Runnable() {

    public void run() {

    // When Exit is tapped, close the application

    removeItems();

    Display.getDisplay(parent).setCurrent(null);

    parent.notifyDestroyed();

    }

    });

    this.loginButton = new Button(

    this, "Log in",

    new Runnable() {

    public void run() {

    // When Login is tapped, create a new screen and set it current

    if(BlogWriter.isAshaPlatform())

    removeItems();

    EditScreen editScreen = new EditScreen(parentDisplay);

    editScreen.setParent(parent);

    parentDisplay.setCurrent(editScreen);

    }

    });

    // Disable Login button - it is enabled once username and password are entered

    this.loginButton.setEnabled(false);

    } catch (Exception ex) {

    this.parentDisplay.setCurrent(

    new Alert("Cannot create controls."),

    this);

    }

    // Create the logo image

    try {

    this.logoImage = Image.createImage("midlets/blogwriter/images/LogoImage.png");

    } catch (IOException e) {

    this.parentDisplay.setCurrent(

    new Alert("Cannot create graphics."), this);

    }

    // Set the default position of items and buttons

    this.layoutControls();

    this.userNameTextBox.setVisible(true);

    if (!BlogWriter.isFullTouch() && !BlogWriter.isAshaPlatform()) {

    this.userNameTextBox.setFocused(true);

    }

    this.passwordTextBox.setVisible(true);

    }

    開發者ID:mozilla,項目名稱:pluotsorbet,代碼行數:70,

    示例20: createImage

    ​點讚 2

    import javax.microedition.lcdui.Image; //導入方法依賴的package包/類

    public static javax.microedition.lcdui.Image createImage(byte[] b, int i1, int i2) {

    return Image.createImage(0,0);

    }

    開發者ID:Orange-OpenSource,項目名稱:matos-profiles,代碼行數:4,

    示例21: loadImage

    ​點讚 2

    import javax.microedition.lcdui.Image; //導入方法依賴的package包/類

    private Image loadImage(String url)

    {

    Image image = null;

    if (image == null)

    {

    try

    {

    StreamConnection connection = ProtocolFactory.getInstance().getConnection(url);

    InputStream is = connection.openInputStream();

    ByteArrayOutputStream bos = new ByteArrayOutputStream();

    byte[] buf = new byte[1024];

    int bytesRead;

    do

    {

    bytesRead = is.read(buf);

    if (bytesRead > 0)

    {

    bos.write(buf, 0, bytesRead);

    }

    }

    while (bytesRead >= 0);

    buf = bos.toByteArray();

    //#debug

    System.out.println("Image requested: " + url);

    image = Image.createImage(buf, 0, buf.length);

    // this.imageCache.put(url, image);

    return image;

    }

    catch (Exception e)

    {

    // TODO: Implement proper error handling.

    //#debug debug

    e.printStackTrace();

    return null;

    }

    }

    return image;

    }

    開發者ID:okoskimi,項目名稱:Xfolite,代碼行數:48,

    示例22: imageCreateFromByteArray

    ​點讚 2

    import javax.microedition.lcdui.Image; //導入方法依賴的package包/類

    public Object imageCreateFromByteArray(byte[] data, int offset, int length) {

    return Image.createImage(data, offset, length);

    }

    開發者ID:mozilla,項目名稱:pluotsorbet,代碼行數:4,

    示例23: loadImageInternal

    ​點讚 2

    import javax.microedition.lcdui.Image; //導入方法依賴的package包/類

    private Image loadImageInternal(String url)

    {

    Image image = null; // (Image) this.imageCache.get(url);

    if (image == null)

    {

    try

    {

    StreamConnection connection = ProtocolFactory.getInstance().getConnection(url);

    InputStream is = connection.openInputStream();

    ByteArrayOutputStream bos = new ByteArrayOutputStream();

    byte[] buf = new byte[1024];

    int bytesRead;

    do

    {

    bytesRead = is.read(buf);

    if (bytesRead > 0)

    {

    bos.write(buf, 0, bytesRead);

    }

    }

    while (bytesRead >= 0);

    buf = bos.toByteArray();

    //#debug

    System.out.println("Image requested: " + url);

    image = Image.createImage(buf, 0, buf.length);

    // this.imageCache.put(url, image);

    return image;

    }

    catch (Exception e)

    {

    // TODO: Implement proper error handling.

    //#debug debug

    e.printStackTrace();

    return null;

    }

    }

    return image;

    }

    開發者ID:okoskimi,項目名稱:Xfolite,代碼行數:48,

    示例24: getImage

    ​點讚 1

    import javax.microedition.lcdui.Image; //導入方法依賴的package包/類

    public javax.microedition.lcdui.Image getImage() { return Image.createImage( (Image) null); }

    開發者ID:Orange-OpenSource,項目名稱:matos-profiles,代碼行數:2,

    注:本文中的javax.microedition.lcdui.Image.createImage方法示例整理自Github/MSDocs等源碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。

    展开全文
  • import java.awt.Component; //导入方法依赖的package包/类public void draw(Graphics g, int x, int y, Component obs, double zoom) {if (alpha == 1.0) {piece.draw(g, x, y, obs, zoom);return;}if (opaque.is...

    import java.awt.Component; //导入方法依赖的package包/类

    public void draw(Graphics g, int x, int y, Component obs, double zoom) {

    if (alpha == 1.0) {

    piece.draw(g, x, y, obs, zoom);

    return;

    }

    if (opaque.isChanged()) {

    int trans = VASSAL.tools.TransparentFilter.getOffscreenEquivalent(obs.getBackground().getRGB(), obs);

    VASSAL.tools.TransparentFilter filter = new VASSAL.tools.TransparentFilter();

    filter.setAlpha(alpha);

    filter.setAlpha(0.0, trans);

    im = opaque.getImage(obs);

    Image im2 = obs.createImage(im.getWidth(obs), im.getHeight(obs));

    Graphics2D gg = (Graphics2D) im2.getGraphics();

    gg.drawImage(im, 0, 0, obs);

    gg.dispose();

    im = obs.createImage(new FilteredImageSource

    (im2.getSource(), filter));

    offset = new Point(piece.boundingBox().x,

    piece.boundingBox().y);

    /*

    im = opaque.getImage(obs);

    final Image im2 = obs.createImage(im.getWidth(obs), im.getHeight(obs));

    final Graphics2D gg = (Graphics2D) im2.getGraphics();

    gg.setComposite(

    AlphaComposite.getInstance(AlphaComposite.SRC_OVER, (float) alpha));

    gg.drawImage(im, 0, 0, obs);

    gg.dispose();

    offset = new Point(piece.boundingBox().x,

    piece.boundingBox().y);

    */

    }

    Image scaled = im;

    if (zoom != 1.0) {

    scaled = GameModule.getGameModule().getDataArchive().getScaledImage(im,zoom);

    }

    g.drawImage(scaled,

    x + (int) (zoom * offset.x),

    y + (int) (zoom * offset.y),

    obs);

    }

    展开全文
  • public BufferedImageDemo(){ image = createImage(); addMouseMotionListener(this); } @Override public void mouseDragged(MouseEvent e) { } @Override public void mouseMoved(MouseEvent e) { //创建新的图片...

    通过鼠标位置改变图像ColorModel对象索引,从而实现图像像素自动变化

    BufferedImage 由图像数据的 ColorModel 和 Raster 组成。Raster 的 SampleModel 中 band 的数量和类型必须与 ColorModel 所要求的数量和类型相匹配,以表示其颜色和 alpha 分量。所有 BufferedImage 对象的左上角坐标都为 (0, 0)。因此,用来构造 BufferedImage 的任何 Raster 都必须满足:minX=0 且 minY=0。

    此类依靠 Raster 的数据获取方法、数据设置方法,以及 ColorModel 的颜色特征化方法。

    package chapter2;

    import javax.swing.*;

    import java.awt.*;

    import java.awt.event.MouseEvent;

    import java.awt.event.MouseMotionListener;

    import java.awt.image.*;

    /**

    * Created by LENOVO on 18-1-27.

    */

    public class BufferedImageDemo extends JPanel implements MouseMotionListener{

    private BufferedImage image = null;

    private int width = 350;

    private int height = 350;

    public BufferedImageDemo(){

    image = createImage();

    addMouseMotionListener(this);

    }

    @Override

    public void mouseDragged(MouseEvent e) {

    }

    @Override

    public void mouseMoved(MouseEvent e) {

    //创建新的图片

    image = new BufferedImage(createColorModel(e.getX()),image.getRaster(),false,null);

    repaint();

    }

    public void paintComponent(Graphics g){

    Graphics2D g2d = (Graphics2D) g.create();

    if(image != null){

    g2d.drawImage(image,2,2,width,height,null);

    }

    }

    //颜色特征获取

    private static ColorModel createColorModel(int n){

    byte[] r = new byte[16];

    byte[] g = new byte[16];

    byte[] b = new byte[16];

    for(int i=0;i

    r[i] = (byte) n;

    g[i] = (byte) n;

    b[i] = (byte) n;

    }

    return new IndexColorModel(4,16,r,g,b);

    }

    private BufferedImage createImage(){

    byte[] pixels = new byte[width*height];

    /*

    * public DataBufferByte(byte[] dataArray, int size, int offset)

    使用指定数组、大小和偏移量构造具有单个存储单元且基于字节的 DataBuffer。dataArray

    至少必须有 offset + size 个元素。此 DataBuffer 的访问器只能使用 offset 到 offset + size - 1 个元素。

    * */

    DataBuffer dataBuffer = new DataBufferByte(pixels,width*height,0);

    //SampleModel为抽象类,压缩的样本数据:SinglePixelPackedSampleModel实现类

    //将多个样本打包到一个元素中去

    /*

    * public SinglePixelPackedSampleModel(int dataType,int w, int h,int[] bitMasks)

    * dataType - 存储样本使用的数据类型。

    w - 所描述的图像数据区域的宽度(以像素为单位)。

    h - 所描述的图像数据区域的高度(以像素为单位)。

    bitMasks - 所有 band 的位掩码。

    * */

    SampleModel sampleModel = new SinglePixelPackedSampleModel(DataBuffer.TYPE_BYTE,width,height,new int[]{(byte)0xf});

    //null代表位置为(0,0)

    WritableRaster raster = Raster.createWritableRaster(sampleModel,dataBuffer,null);

    return new BufferedImage(createColorModel(0),raster,false,null);

    }

    public static void main(String args[]){

    JFrame jf = new JFrame("BufferedImage Demo");

    jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    jf.getContentPane().setLayout(new BorderLayout());

    jf.getContentPane().add(new BufferedImageDemo(),BorderLayout.CENTER);

    jf.setPreferredSize(new Dimension(380,380));

    jf.pack();

    jf.setVisible(true);

    }

    }

    展开全文
  • 根据一个文件路径创建Image对象Image image = ImageIO.read(new File(filepath));2.将Image对象保存为文件形式BufferedImage image = ImageIO.read(new File(filepath));//要想保存这个对象的话你要把image声明为...

    一.创建与保存

    1.根据一个文件路径创建Image对象

    Image image = ImageIO.read(new File(filepath));

    2.将Image对象保存为文件形式

    BufferedImage image = ImageIO.read(new File(filepath));//要想保存这个对象的话你要把image声明为BufferedImage 类型

    ImageIO.write(image, "jpg", new File("f:/image/apple.jpg"));

    二.在图像界面中显示图像

    1.使用窗口加载,将图片变为背景显示

    ImageIcon bg =new ImageIcon(image);

    JLabel jl = new JLabel(bg);

    jl.setBounds(0,0,bg.getIconWidth(),bg.getIconHeight());

    jf.setSize(bg.getIconWidth(), bg.getIconHeight());

    jf.setResizable(false);

    //将图片添加到分层窗格的最底层作为背景

    jf.getLayeredPane().add(jl, new Integer(Integer.MIN_VALUE));

    //内容窗格转化为JPanel,否则不能设置为透明

    JPanel jp = (JPanel)getContentPane();

    jp.setLayout(null);

    jp.setOpaque(false);//设置为透明

    2.使用Graphics画笔将图片画在窗口中

    重写窗体类的paint(Graphics g)方法

    public void paint(Graphics g){

    g.drawImage(0,0,400,300,null);   //该方法的主体是窗口

    }

    当然也可以自己写一个画图的方法

    public void draw(Graphics g){

    g.drwaImage(0,0,400,300,null);   //记得传一个Graphics画笔进来

    }

    3.关于Graphics 对象为null的解决

    (1)paint系列方法里的是jre创建的

    (2)当前类继承了jframe的话直接可以这样写的graphics g=getgraphics();

    (3)其他情况通过 Graphics g =new Graphics();出来的对象为null,应该采用下面方法:

    BufferedImage bi = new BufferedImage(120,120, BufferedImage.TYPE_INT_ARGB);

    Graphics2D g2d = bi.createGraphics();

    

    展开全文
  • 尽量不要使用setImageBitmap或setImageResource或BitmapFactory.decodeResource来设置一张大图,因为这些函数在完成decode后,最终都是通过java层的createBitmap来完成的,需要消耗更多内存。因此,改用先通过...
  • 我正在尝试使用LWUIT创建启动画面。我想要一个表单加载并显示文本和图像5秒钟,...java.io.IOException可能是什么问题呢?这是代码package tungPackage;import com.sun.lwuit.Display;import com.sun.lwuit.Form;im...
  • javaimage 和 byte[] 相互转换可恶的…………其实也挺好的只是把好不容易写出来的东西记下来,怕忘了……下面,我来介绍一个简单的 byte[] to image,我们只需要一个存储了图片信息的二进制串(byte[])然后,这样...
  • java 中的图片处理是很让人头疼的一件事情。目前 java api 中的 imageIO 可以将 gif 图片转换成 png 图片, jpg 图片可以正常转换。据说 gif 转 jpg 也是有办法的,但是将 jpg 转成 gif ,我费了很大的工夫才找到一...
  • public static void main(String[] args) throws IOException{Image img = Toolkit.getDefaultToolkit().getImage("C:\\google.jpg");BufferedImage bi_scale = toBufferedImage(img);ImageIO.write(bi_scale, "jpg...
  • 我试图从java.awt.image.BufferedImage写出一个png文件.一切正常,但生成的png是一个32位文件.有没有办法让png文件成为8位?图像是灰度图像,但我确实需要透明度,因为这是一个叠加图像.我正在使用java 6,我宁愿返回一...
  • There are times when this will not always be the case and you need to stretch or shrink the image, and there are two ways to do achieve this. The first is to use the GC to stretch and clip it, using G...
  • 原因…JavaCV 0.11引入了FrameConverter的概念.目标是不要在使用JavaCV的应用程序和另一个API(FFmpeg,Java 2D ……)之间创建不必要的耦合....解决方法……始终可以将createFrom方法的代码复制并粘贴到您自己的代码...
  • 我试图从java.awt.image.BufferedImage写出一个png文件.一切正常,但生成的png是一个32位文件.有没有办法让png文件成为8位?图像是灰度图像,但我确实需要透明度,因为这是一个叠加图像.我正在使用java 6,我宁愿返回一...
  • 我从oracle过程中读取了clob,并通过以下代码将它们转换为java.awt.Image对象.InputStream stream = clob.getAsciiStream();ByteArrayOutputStream output = new ByteArrayOutputStream();int a1 = stream.read();...
  • package beckey.util;import java.awt.Color;import java.awt.Font;import java.awt....import java.awt.image.BufferedImage;import java.util.Random;import javax.servlet.http.HttpSession;public class I...
  • I draw graphics in frame with this methods.public void paint(Graphics g) {screenImage = createImage(1280, 720);screenGraphic = screenImage.getGraphics();screenDraw((Graphics2D) screenGraphic);//g.draw...
  • import java.awt.Color; import java.awt.Font; public class Grid { private boolean show; private int row; //对应Excel中的row,也可以理解为cells[i][j]的i private int col; //对应Excel中的col,也可以...
  • I've looked all over the place, but can't seem to find any easy to understand ... (I've found classes and methods written by other Java users that can do this, but I'm hoping to write my own....
  • Java 应用程序中创建图像在不严重牺牲性能的前提下绘制和着色简单的图形图像Ivor Horton2001 年 2 月 02 日发布合成图像您不必从文件中读取所有的图像 ―您可以创建自己的图像。要创建自己的图像,最灵活的方法是...
  • Posted by:wgz_jzPosted ...但现在的问题是Image字段内容已读到了BufferedInputStream中,但是 jLabel1.SetIcon(...)就是显示不出来,而加载一张图片文件就可以显示出来,请问这个问题该如何解决?(IDE 是 JBuilderX...
  • 第一步:建立数据库create table test_img(id number(4),name varchar(20),img long raw);第二步:(NewImg.html)添加图片添加图片图像ID:选择图像:第三步:插入数据库(InsertImg.jsp)Class.forName("oracle.jdbc....
  • private static String getFormatName(Object o) { try { // Create an image input stream on the image ImageInputStream iis = ImageIO.createImageInputStream(o); // Find all image ...
  • It is reversed problem to:How can I call/execute a java program from an ImageJ ...Whenever I write imagej I refer to fiji.Of course a trivial solution is to create a .ijm from java string and call ...
  • 这显然是一个知识错误,我看到了一些建议(this是一个)建议使用Toolkit#createImage,这显然忽略了颜色模型.我测试了它,似乎工作正常.public class TestImageIO01 {public static void main(String[] args) {try {Image...
  • 如果您正苦於以下問題:Java Image.setRotationDegrees方法的具體用法?Java Image.setRotationDegrees怎麽用?Java Image.setRotationDegrees使用的例子?那麽恭喜您, 這裏精選的方法代碼示例或...
  • public class MaxMinPictu extends JFrame{ // public static void resizeImage(FileInputStream is,int size) throws IOException { System.out.println("yyyyyyyyyyyyyyy"); //String file1 = "file/e.png"; //...
  • 背景随着Android 7.1推出Round Icon Resources功能(不了解的,可以看Android开发者官网这篇文章Android 7.1 for ...尽管Image Asset Studio为我们制作ICON提供了丰富的功能,但对于一个没有美工基础特别是个人开...
  • Java Image功能一直都在增强,但是向磁盘写一个图像文件或者返回一个PNG或JPEG依然比较难实现。但是我们可以使用Java Advanced Imaging(JAI)API来解决这个问题。JAI可以从SUN的Java站点下载,它包含在JDK 1.4的javax...
  • java demo里的例子publicstaticImagegetImage(Stringname,Componentcmp){Imageimg=null;URLClassLoaderurlLoader=(URLClassLoader)cmp.getClass().getClassLoader();URLfileLoc=urlLoader.findResource(...

空空如也

空空如也

1 2 3 4 5 ... 20
收藏数 104,449
精华内容 41,779
关键字:

java的createimage

java 订阅