⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 greetingcardimage.java

📁 greetingcard是手机贺卡的制作软件。小程序
💻 JAVA
字号:
import java.io.DataInputStream;
import javax.microedition.lcdui.Image;
import javax.microedition.lcdui.Graphics;


public class GreetingCardImage {
    
    public static Image currentScreen;
    public static Image nextScreen;
    public static Image[] cardScreens;
    private GreetingCardScreen cardScreen;
    private int totalScreen;
    public boolean newImage;
    private int splashLen;
    private byte[] content;
    public boolean transition = true;
    private int transitionDone;
    private int idx = 0;
    
    public GreetingCardImage(GreetingCardPlayer cardPlayer, String splashLen, DataInputStream dis) 
    {
        try 
        {
            this.splashLen = Integer.parseInt(splashLen);
            content = new byte[this.splashLen];
            dis.readFully(content, 0, this.splashLen);
            currentScreen = Image.createImage(content, 0, this.splashLen);
            totalScreen = 3;
        } 
        catch(Exception ex) 
        {
            //Do Nothing
        }
    }
    
    private Image getScreenshot(int idx) 
    {
       try 
       {
    	   newImage = true;
           return cardScreens[idx];
       } 
       catch(Exception e) 
       {
          newImage = false;	       
       }
       return null;
    }

    public void blindsVerticalToLeft(Graphics g, int w, int h) 
    {
    	int x = 0;
        int n = 1;
        int dw = (w/n) * transitionDone / 100;
        
        if(idx > 0)
        {
        	x = idx -1;
        }
        else
        {
        	x = idx;
        }
        for(int i = 0; i < n; i++) 
        {
            g.setClip(w/n*i, 0, dw, h);
	            g.drawImage(getScreenshot(x), w/2, h/2, 
	              Graphics.HCENTER|Graphics.VCENTER);
        }
    }
    
 
    public void slideTransition() 
    {
      transitionDone = 100;
      int speed = 5;
      while(transitionDone > 0) 
      {
    	  cardScreen.repaint();  
    	  cardScreen.serviceRepaints();
          transitionDone -= speed;
          try 
          { 
        	  Thread.sleep(20); 
          } 
          catch(Exception e) 
          {}
        }
    }

    public Image getNextPage()
    {
    	idx = 2;
        nextScreen = getScreenshot(idx);
        return nextScreen;
    }
    
    public void firstPage() 
    {
        currentScreen = null;
        currentScreen = cardScreens[0];
        nextScreen = getScreenshot(0); 
        idx = 0;
    }
    
    public void secondPage() 
    {
    	idx = 1;
        nextScreen = getScreenshot(idx);        
        slideTransition();
    }
    
    public void thirdPage() 
    {
    	idx = 2;
        nextScreen = getScreenshot(idx);        
        slideTransition();
    }
    
    public void redofirstPage() 
    {
    	idx = 0;
        nextScreen = getScreenshot(idx);        
        slideTransition();
    }
    
    public void setGreetingCardScreen(GreetingCardScreen cardScreen)
    {
    	this.cardScreen = cardScreen;
    	cardScreens = new Image[totalScreen];
    	try
    	{
    		for(int i = 0; i < totalScreen; i++)
    		{
    			cardScreens[i] = cardScreen.resizeImage(Image.createImage("/p" + i + ".png"));
    		}
    	}
    	catch(Exception ex)
    	{
    		//Do Nothing
    	}
    }
    
    
    public void drawCardScreen(Graphics g, int w, int h) 
    {
        if(currentScreen == null)
          return;

        g.drawImage(getScreenshot(idx), w/2, h/2, 
        		Graphics.HCENTER|Graphics.VCENTER);

        blindsVerticalToLeft(g,w, h);
        g.setClip(0, 0, w, h);
    }
    
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -