drawimage的用法 java_Java Graphics.drawImage方法代码示例

本文整理汇总了Java中javax.microedition.lcdui.Graphics.drawImage方法的典型用法代码示例。如果您正苦于以下问题:Java Graphics.drawImage方法的具体用法?Java Graphics.drawImage怎么用?Java Graphics.drawImage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.microedition.lcdui.Graphics的用法示例。

在下文中一共展示了Graphics.drawImage方法的30个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: DrawGif

​点赞 3

import javax.microedition.lcdui.Graphics; //导入方法依赖的package包/类

/**

* ��GIFͼ��

* @param imgpath ͼ��·��

* @param xx����

* @param yy����

*/

private void DrawGif(String imgpath,int x,int y)

{

Graphics g=getGraphics();

if(imgpath!=prepath)

{

prepath=imgpath;//�ѵ�ǰͼ��·������ǰһ��

gifd.read(this.getClass().getResourceAsStream(imgpath));//����ͼƬ

framecount= gifd.getFrameCount();//��ȡ֡��

}

for(int i=0;i

{

g.drawImage(gifd.getFrame(i), x, y, anchor);

try {

Thread.sleep(FrameInterval);

} catch (InterruptedException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

flushGraphics();

}

}

开发者ID:cabbage89,项目名称:danceGame,代码行数:28,

示例2: ShowLift

​点赞 3

import javax.microedition.lcdui.Graphics; //导入方法依赖的package包/类

/**

* ������ͷ

* @param n Ҫ���ĸ���

*/

private void ShowLift(int n)

{

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

int startpos=0;

Graphics grap=getGraphics();

if(n!=3)

{

//����ǻ�����˵���dz�ʼ��,����������Ҫ�������

grap.drawImage(liftbg, 0, 0, anchor);///����ͷ�������

}

for(int i=1;i<=n;i++)

{

grap.drawImage(lift, startpos, 0, anchor);//ÿ�λ�һ������17����

startpos+=17;

}

flushGraphics();

}

开发者ID:cabbage89,项目名称:danceGame,代码行数:22,

示例3: ShowLightBg

​点赞 3

import javax.microedition.lcdui.Graphics; //导入方法依赖的package包/类

/**

* ��ʾ��ɫ�ĵ�

* @param state ����״̬

* @param n��ʾ������

*/

private void ShowLightBg(Light state,int n)

{

Graphics gra=getGraphics();

gra.drawImage(passarea, 0, py, anchor);//���±���

int startpos=0;

for(int i=1;i<=n;i++)

{

if(state==Light.dark)

{

gra.drawImage(passbg, startpos, py, anchor);

}

startpos+=15;//ˮƽƫ��һ��ͼƬ��

}

flushGraphics();

}

开发者ID:cabbage89,项目名称:danceGame,代码行数:21,

示例4: init

​点赞 3

import javax.microedition.lcdui.Graphics; //导入方法依赖的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,

示例5: ShowLift

​点赞 3

import javax.microedition.lcdui.Graphics; //导入方法依赖的package包/类

/**

* ������ͷ

* @param n Ҫ���ĸ���

*/

private void ShowLift(int n)

{

int startpos=0;

Graphics grap=getGraphics();

if(n!=3)

{

//����ǻ�����˵���dz�ʼ��,����������Ҫ�������

grap.drawImage(liftbg, 0, 0, anchor);///����ͷ�������

}

for(int i=1;i<=n;i++)

{

grap.drawImage(lift, startpos, 0, anchor);//ÿ�λ�һ������17����

startpos+=17;

}

flushGraphics();

}

开发者ID:cabbage89,项目名称:danceGame,代码行数:21,

示例6: Fail

​点赞 3

import javax.microedition.lcdui.Graphics; //导入方法依赖的package包/类

/**

* ���˶���ʧ��

*/

private void Fail()

{

ShowLightBg(Light.dark, ActionCount);//���а�ɫ�Ʊ���

Graphics gra=getGraphics();

int startpos=0;

for(int i=1;i<=rightcount;i++)

{

gra.drawImage(pass, startpos, py, anchor);

startpos+=15;

}

gra.drawImage(notpass, 15*rightcount, py, anchor);//���ƴ����

flushGraphics();

currentLift--;//��������1

ShowLift(currentLift);//��ʾ������

if(currentLift==0)

{

//GameOver

Gameover();

}

else

{

CurrentPressindex=ActionCount;//ʹС����������

}

}

开发者ID:cabbage89,项目名称:danceGame,代码行数:28,

示例7: doRight

​点赞 3

import javax.microedition.lcdui.Graphics; //导入方法依赖的package包/类

/**

* ���˶������Ե�ָʾ

* @param n ���ԵĴ���

*/

private void doRight(int n)

{

int startpos=0;

Graphics gra=getGraphics();

for(int i=1;i<=n;i++)

{

gra.drawImage(pass, startpos, py, anchor);

startpos+=15;//ˮƽƫ��һ��ͼƬ��

}

for(int i=1;i<=ActionCount-n;i++)

{

gra.drawImage(passbg, startpos, py, anchor);

}

flushGraphics();

}

开发者ID:cabbage89,项目名称:danceGame,代码行数:20,

示例8: paint

​点赞 3

import javax.microedition.lcdui.Graphics; //导入方法依赖的package包/类

/**

* Draw the item.

*/

protected void paint(final Graphics g, final int w, final int h) {

int y = 0;

String loginStatus = "";

if (session.isLoggedIn()) {

loginStatus = "Logged in as " + session.getUsername();

}

else {

loginStatus = "Not logged in";

}

g.setColor(VisualStyles.COLOR_FOREGROUND);

g.setFont(FONT_TEXT);

g.drawString(loginStatus, w - H_SPACE * 2, y, Graphics.TOP

| Graphics.RIGHT);

g.setColor(VisualStyles.COLOR_FOREGROUND_DIM);

if (separatorImage != null) {

y = height - separatorImage.getHeight() - V_SPACE;

g.drawImage(separatorImage, 0, y, Graphics.TOP | Graphics.LEFT);

}

}

开发者ID:mozilla,项目名称:pluotsorbet,代码行数:26,

示例9: paint

​点赞 3

import javax.microedition.lcdui.Graphics; //导入方法依赖的package包/类

/**

* Draw the item.

*/

protected void paint(final Graphics g, final int w, final int h) {

g.setColor(VisualStyles.COLOR_FOREGROUND_DIM);

g.setFont(FONT);

final int y = V_SPACE * 2;

final int fontOffset = FONT.getHeight() / 2;

final int vote = item.getVote();

final int leftX = H_SPACE * 2;

final int rightX = w - 2 * H_SPACE;

g.drawImage(vote == -1 ? voteDownActiveImage : voteDownImage, leftX, y,

Graphics.TOP | Graphics.LEFT);

g.drawImage(vote == 1 ? voteUpActiveImage : voteUpImage, rightX, y,

Graphics.TOP | Graphics.RIGHT);

g.drawString("Vote down", leftX + voteImageWidth + H_SPACE, y

+ fontOffset, Graphics.TOP | Graphics.LEFT);

g.drawString("Vote up", rightX - voteImageWidth - H_SPACE, y

+ fontOffset, Graphics.TOP | Graphics.RIGHT);

}

开发者ID:mozilla,项目名称:pluotsorbet,代码行数:23,

示例10: init

​点赞 2

import javax.microedition.lcdui.Graphics; //导入方法依赖的package包/类

/**

* ��Ϸ��ʼ��

*/

private void init(boolean hasreadhistory)

{

if(hasreadhistory)

{

try

{

System.out.println("��ʼ��ȡ�ϴ���Ϸ��¼...");

readhistory();

if(currentLift<=0)

{

currentScore=0;

ActionCount=2;

ActionRepeat=6;

currentLift=3;

}

System.out.println("��Ϸ��¼��ȡ���...");

}

catch(Exception e)

{

//�����ع�

currentScore=0;

ActionCount=2;

ActionRepeat=6;

currentLift=3;

System.out.println("��ʼ��ʱ��ȡrmsʧ��..."+e);

}

}

Graphics gra=getGraphics();

gra.drawImage(bg, 0, 0, anchor);//����

ShowLift(currentLift);//����������ͷ

ShowScore(currentScore);//

flushGraphics();

}

开发者ID:cabbage89,项目名称:danceGame,代码行数:37,

示例11: DrawOld

​点赞 2

import javax.microedition.lcdui.Graphics; //导入方法依赖的package包/类

/**

* �����˶���

* @param dir ����

*/

private void DrawOld(Dir dir)

{

Graphics gra=getGraphics();

int x=sw-o1.getWidth();

if(dir==Dir.d1)

{

gra.drawImage(o1, x, oy, anchor);

}

else if(dir==Dir.d3)

{

gra.drawImage(o3, x, oy, anchor);

}

else if(dir==Dir.d7)

{

gra.drawImage(o7, x, oy, anchor);

}

else if(dir==Dir.d9)

{

gra.drawImage(o9, x, oy, anchor);

}

else if(dir==Dir.ready)

{

gra.drawImage(oready, x, oy, anchor);

}

flushGraphics();

}

开发者ID:cabbage89,项目名称:danceGame,代码行数:31,

示例12: Fail

​点赞 2

import javax.microedition.lcdui.Graphics; //导入方法依赖的package包/类

/**

* ���˶���ʧ��

*/

private void Fail()

{

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

if(exit)

{

//������û������ؼ�����ʧ��,����������߼�

System.out.println("�û��˳�����ʧ��...");

return;

}

ShowLightBg(Light.dark, ActionCount);//���а�ɫ�Ʊ���

Graphics gra=getGraphics();

int startpos=0;

for(int i=1;i<=rightcount;i++)

{

gra.drawImage(pass, startpos, py, anchor);

startpos+=15;

}

gra.drawImage(notpass, 15*rightcount, py, anchor);//���ƴ����

flushGraphics();

currentLift--;//��������1

if(currentLift==0)

{

//GameOver

Gameover();

}

else

{

ShowLift(currentLift);//��ʾ������

CurrentPressindex=ActionCount;//ʹС����������

}

}

开发者ID:cabbage89,项目名称:danceGame,代码行数:35,

示例13: doRight

​点赞 2

import javax.microedition.lcdui.Graphics; //导入方法依赖的package包/类

/**

* ���˶������Ե�ָʾ

* @param n ���ԵĴ���

*/

private void doRight(int n)

{

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

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

try

{

Play(ispass, 1);

}

catch(Exception e)

{

System.out.println("��������ʧ��:"+e);

}

currentScore++;

ShowScore(currentScore);

int startpos=0;

Graphics gra=getGraphics();

for(int i=1;i<=n;i++)

{

gra.drawImage(pass, startpos, py, anchor);

startpos+=15;//ˮƽƫ��һ��ͼƬ��

}

for(int i=1;i<=ActionCount-n;i++)

{

gra.drawImage(passbg, startpos, py, anchor);

}

flushGraphics();

}

开发者ID:cabbage89,项目名称:danceGame,代码行数:32,

示例14: init

​点赞 2

import javax.microedition.lcdui.Graphics; //导入方法依赖的package包/类

/**

* ��Ϸ��ʼ��

*/

private void init()

{

Graphics gra=getGraphics();

gra.drawImage(bg, 0, 0, anchor);//����

ShowLift(3);//����������ͷ

ShowScore(0);

flushGraphics();

}

开发者ID:cabbage89,项目名称:danceGame,代码行数:12,

示例15: paint

​点赞 2

import javax.microedition.lcdui.Graphics; //导入方法依赖的package包/类

protected void paint(Graphics g) {

listener.onPaint(graphics);

if (isLandscape) {

g.drawRegion(image, 0, 0, width, height, Sprite.TRANS_ROT90,

0, 0, Graphics.TOP | Graphics.LEFT);

} else {

g.drawImage(image, 0, 0, Graphics.TOP | Graphics.LEFT);

}

}

开发者ID:aNNiMON,项目名称:JECP,代码行数:10,

示例16: paint

​点赞 2

import javax.microedition.lcdui.Graphics; //导入方法依赖的package包/类

protected void paint(Graphics g, int w, int h) {

// Fill the button with grey color - background

g.setColor(0, 0, 0);

g.fillRect(0, 0, w, h);

// Draw the image in the center of the button

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

// Draw the borders

g.setColor(0x000000);

g.drawLine(0, 0, w, 0);

g.drawLine(0, 0, 0, h);

g.drawLine(0, h-1, w, h-1);

g.drawLine(w-1, 0, w-1, h);

}

开发者ID:dimagi,项目名称:commcare-j2me,代码行数:14,

示例17: createThumbnail

​点赞 2

import javax.microedition.lcdui.Graphics; //导入方法依赖的package包/类

public static Image createThumbnail(Image image) {

int sourceWidth = image.getWidth();

int sourceHeight = image.getHeight();

int thumbWidth = 64;

int thumbHeight = -1;

if (thumbHeight == -1)

thumbHeight = thumbWidth * sourceHeight / sourceWidth;

Image thumb = Image.createImage(thumbWidth, thumbHeight);

Graphics g = thumb.getGraphics();

for (int y = 0; y < thumbHeight; y++) {

for (int x = 0; x < thumbWidth; x++) {

g.setClip(x, y, 1, 1);

int dx = x * sourceWidth / thumbWidth;

int dy = y * sourceHeight / thumbHeight;

g

.drawImage(image, x - dx, y - dy, Graphics.LEFT

| Graphics.TOP);

}

}

Image immutableThumb = Image.createImage(thumb);

return immutableThumb;

}

开发者ID:dimagi,项目名称:commcare-j2me,代码行数:29,

示例18: resizeImage

​点赞 2

import javax.microedition.lcdui.Graphics; //导入方法依赖的package包/类

/**

* This methog resizes an image by resampling its pixels

* @param src The image to be resized

* @return The resized image

*/

public static Image resizeImage(Image src, int newWidth, int newHeight) {

//We need to make sure we have memory available if it exists, because we're going to be allocating huuuge

//chunks, and that might fail even if those chunks would be available if we collected.

Runtime.getRuntime().gc();

int srcWidth = src.getWidth();

int srcHeight = src.getHeight();

Image tmp = Image.createImage(newWidth, srcHeight);

Graphics g = tmp.getGraphics();

int ratio = (srcWidth << 16) / newWidth;

int pos = ratio/2;

//Horizontal Resize

for (int x = 0; x < newWidth; x++) {

g.setClip(x, 0, 1, srcHeight);

g.drawImage(src, x - (pos >> 16), 0, Graphics.LEFT | Graphics.TOP);

pos += ratio;

}

Image resizedImage = Image.createImage(newWidth, newHeight);

g = resizedImage.getGraphics();

ratio = (srcHeight << 16) / newHeight;

pos = ratio/2;

//Vertical resize

for (int y = 0; y < newHeight; y++) {

g.setClip(0, y, newWidth, 1);

g.drawImage(tmp, 0, y - (pos >> 16), Graphics.LEFT | Graphics.TOP);

pos += ratio;

}

return resizedImage;

}

开发者ID:dimagi,项目名称:commcare-j2me,代码行数:42,

示例19: drawBuffer

​点赞 2

import javax.microedition.lcdui.Graphics; //导入方法依赖的package包/类

/**

* Render the off-screen buffer content to the Graphics object

* @param g the Graphics object to render off-screen buffer content

*/

public void drawBuffer(Graphics g) {

// NullPointerException will be thrown in drawImage if g == null

if (offscreenBuffer != null) {

g.drawImage(offscreenBuffer, 0, 0,

Graphics.TOP | Graphics.LEFT);

}

}

开发者ID:mozilla,项目名称:pluotsorbet,代码行数:12,

示例20: paint

​点赞 2

import javax.microedition.lcdui.Graphics; //导入方法依赖的package包/类

protected void paint(Graphics graphics) {

int imagePosition = 0;

// Draw background image

if (this.background != null) {

graphics.drawImage(

this.background,

0, imagePosition,

Graphics.TOP | Graphics.LEFT);

}

}

开发者ID:mozilla,项目名称:pluotsorbet,代码行数:11,

示例21: paint

​点赞 2

import javax.microedition.lcdui.Graphics; //导入方法依赖的package包/类

/**

* Paint the state. Should be called from Button's paint method.

*/

public void paint(Graphics gfx, String text) {

gfx.drawImage(

background,

owner.getWidth() / 2, owner.getHeight() / 2,

Graphics.VCENTER | Graphics.HCENTER);

gfx.setColor(0x000000);

gfx.drawRect(0, 0, owner.getWidth() - 1, owner.getHeight() - 1);

gfx.setColor(this.labelColor);

gfx.drawString(

text,

owner.getWidth() / 2, (owner.getHeight() / 3) * 2,

Graphics.BASELINE | Graphics.HCENTER);

}

开发者ID:mozilla,项目名称:pluotsorbet,代码行数:17,

示例22: paint

​点赞 2

import javax.microedition.lcdui.Graphics; //导入方法依赖的package包/类

protected void paint(Graphics graphics) {

super.paint(graphics);

// Draw logo

if (this.logoImage != null) {

graphics.drawImage(this.logoImage, getWidth() / 2, 0, Graphics.TOP | Graphics.HCENTER);

}

}

开发者ID:mozilla,项目名称:pluotsorbet,代码行数:8,

示例23: paint

​点赞 2

import javax.microedition.lcdui.Graphics; //导入方法依赖的package包/类

protected void paint( Graphics g ){

g.setColor(0, 0, 0);

g.fillRect(0, 0, getWidth(), getHeight());

g.drawImage( iImage, x , y, Graphics.TOP | Graphics.LEFT );

if( x + iImageWidth - getWidth() < 0 )

g.drawImage( iImage, x + iImageWidth, y, Graphics.TOP | Graphics.LEFT );

}

开发者ID:mozilla,项目名称:pluotsorbet,代码行数:9,

示例24: paint

​点赞 2

import javax.microedition.lcdui.Graphics; //导入方法依赖的package包/类

/**

* Draw the item.

*/

protected void paint(final Graphics g, final int w, final int h) {

final String dateStr = DatePrettyPrinter.prettyPrint(link.getCreated());

final String numCommentsStr = "" + link.getNumComments() + " comments";

final int ncHeight = FONT_SEPARATOR.getHeight() + SEPARATOR_V_SPACE;

int x = H_SPACE;

int y = V_SPACE;

g.setColor(VisualStyles.COLOR_FOREGROUND);

g.setFont(FONT_TEXT);

g.drawString("by " + link.getAuthor(), x, y, Graphics.TOP

| Graphics.LEFT);

g.drawString(dateStr, w - H_SPACE * 2, y, Graphics.TOP

| Graphics.RIGHT);

// Draw left and right part of the separator, then the score in the middle

y = height - ncHeight - V_SPACE / 2;

g.setColor(VisualStyles.COLOR_FOREGROUND_DIM);

if (separatorImage != null) {

g.drawImage(separatorImage, w / 2, y + ncHeight / 2, Graphics.TOP

| Graphics.HCENTER);

}

g.setFont(FONT_SEPARATOR);

g.drawString(numCommentsStr, w / 2, y - 4, Graphics.TOP

| Graphics.HCENTER);

}

开发者ID:mozilla,项目名称:pluotsorbet,代码行数:31,

示例25: drawImage

​点赞 2

import javax.microedition.lcdui.Graphics; //导入方法依赖的package包/类

private void drawImage(Graphics g, int x, int y, int offX, int offY) throws IOException {

Image img = TileCacheManager.loadImage(zoom, x, y, mapSource, null);

if (img != null) {

g.drawImage(img, offX, offY, Graphics.TOP | Graphics.LEFT);

} else {

// If img IS null, then a repaint() is later called

g.setColor(0, 0, 0);

g.drawString("Loading...", offX, offY, Graphics.TOP | Graphics.LEFT);

TileCacheManager.loadImage(zoom, x, y, mapSource, this);

}

}

开发者ID:cli,项目名称:worldmap-classic,代码行数:13,

示例26: ShowScore

​点赞 2

import javax.microedition.lcdui.Graphics; //导入方法依赖的package包/类

/**

* ��ʾ����

* @param score ����

*/

private void ShowScore(int score)

{

Graphics gra=getGraphics();

Image[] imgarr=new Image[]{n0,n1,n2,n3,n4,n5,n6,n7,n8,n9};

int num0=0,num1=0,num2=0,num3=0;//��ʮ��ǧ

int startposx=0,startposy=0;

if(!exit)

{

//����Ϸ����ʾ

startposx=40;

startposy=0;

gra.drawImage(scorearea, sw-startposx, 0, anchor);//���±���

}

else

{

startposx=108;

startposy=61;

//��Ϸ������ʾ

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

}

if(score<10)

{

//һλ��

num0=score;

gra.drawImage(imgarr[num0], sw-startposx, startposy, anchor);

}

else if(score>9&&score<100)

{

//���

num0=score%10;

num1=(score-num0)/10;

gra.drawImage(imgarr[num1], sw-startposx, startposy, anchor);

gra.drawImage(imgarr[num0], sw-startposx+10, startposy, anchor);

}

else if(score>99&&score<1000)

{

num0=score%10;

int temp=(score-num0)/10;//��λΪ0ʱ��ʮ��֮һ

num1=temp%10;

num2=(temp-num1)/10;

gra.drawImage(imgarr[num2], sw-startposx, startposy, anchor);

gra.drawImage(imgarr[num1], sw-startposx+10, startposy, anchor);

gra.drawImage(imgarr[num0], sw-startposx+20, startposy, anchor);

}

else if(score>999&&score<10000)

{

num0=score%10;//��λ,��1234,��ʱ4

int temp1=(score-num0)/10;//��λΪ0ʱ��ʮ��֮һ,��ʱ123

num1=temp1%10;//ʮλ,3

int temp2=(temp1-num1)/10; //12

num2=temp2%10;//2

num3=(temp2-num2)/10;

gra.drawImage(imgarr[num3], sw-startposx, startposy, anchor);

gra.drawImage(imgarr[num2], sw-startposx+10, startposy, anchor);

gra.drawImage(imgarr[num1], sw-startposx+20, startposy, anchor);

gra.drawImage(imgarr[num0], sw-startposx+30, startposy, anchor);

}

flushGraphics();

}

开发者ID:cabbage89,项目名称:danceGame,代码行数:65,

示例27: ShowScore

​点赞 2

import javax.microedition.lcdui.Graphics; //导入方法依赖的package包/类

/**

* ��ʾ����

* @param score ����

*/

protected void ShowScore(int score)

{

Graphics gra=getGraphics();

Image[] imgarr=new Image[]{n0,n1,n2,n3,n4,n5,n6,n7,n8,n9};

int num0=0,num1=0,num2=0,num3=0;//��ʮ��ǧ

int startposx=0,startposy;

if(!exit)

{

//����Ϸ����ʾ

startposx=40;

startposy=0;

gra.drawImage(scorearea, sw-startposx, 0, anchor);//���±���

}

else

{

startposx=68;

startposy=71;

//��Ϸ������ʾ

}

if(score<10)

{

//һλ��

num0=score;

gra.drawImage(imgarr[num0], sw-startposx, startposy, anchor);

}

else if(score>9&&score<100)

{

//���

num0=score%10;

num1=(score-num0)/10;

gra.drawImage(imgarr[num1], sw-startposx, startposy, anchor);

gra.drawImage(imgarr[num0], sw-startposx-10, startposy, anchor);

}

else if(score>99&&score<1000)

{

num0=score%10;

int temp=(score-num0)/10;//��λΪ0ʱ��ʮ��֮һ

num1=temp%10;

num2=(temp-num1)/10;

gra.drawImage(imgarr[num2], sw-startposx, startposy, anchor);

gra.drawImage(imgarr[num1], sw-startposx-10, startposy, anchor);

gra.drawImage(imgarr[num0], sw-startposx-20, startposy, anchor);

}

else if(score>999&&score<10000)

{

num0=score%10;//��λ,��1234,��ʱ4

int temp1=(score-num0)/10;//��λΪ0ʱ��ʮ��֮һ,��ʱ123

num1=temp1%10;//ʮλ,3

int temp2=(temp1-num1)/10; //12

num2=temp2%10;//2

num3=(temp2-num2)/10;

gra.drawImage(imgarr[num3], sw-startposx, startposy, anchor);

gra.drawImage(imgarr[num2], sw-startposx-10, startposy, anchor);

gra.drawImage(imgarr[num1], sw-startposx-20, startposy, anchor);

gra.drawImage(imgarr[num0], sw-startposx-30, startposy, anchor);

}

flushGraphics();

}

开发者ID:cabbage89,项目名称:danceGame,代码行数:64,

示例28: paintContent

​点赞 2

import javax.microedition.lcdui.Graphics; //导入方法依赖的package包/类

protected void paintContent(int x, int y, int leftBorder, int rightBorder, Graphics g) {

if(player != null) {

//center stuff

width = rightBorder - leftBorder;

int offsetX = (width - cw) / 2;

vc.setDisplayLocation(x + offsetX, y);

if(!playing) {

vc.setVisible(false);

Font f = g.getFont();

int fnth = f.getHeight();

//Calculate margins and locations

int mx = x + offsetX;

int my = y;

int mw = vc.getDisplayWidth();

int mh = vc.getDisplayHeight();

int hi = Math.max((int)Math.floor(.2 * mh), fnth);

int fh = mh - hi * 2;

//int fw = mw - wi * 2;

//int wi = (int)Math.floor(.2 * mw);

int fw = (int)Math.floor(.9 * fh);

int wi = (mw - fw)/2;

int wu = (int)Math.floor(fw / 5.0);

int hu = (int)Math.floor(fh / 7.0);

if(hashKeyImage == null) {

hashKeyImage = ImageUtils.getImage(imageLocation);

if(hashKeyImage != null){

//scale

int[] newDimension = ImageUtils.getNewDimensions(hashKeyImage, fw,fh);

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

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

}

}

}

if(hashKeyImage != null) {

g.drawImage(hashKeyImage, mx + wi + fw / 2, my + hi + fh / 2, Graphics.HCENTER | Graphics.VCENTER);

} else {

//Draw us a big 'ol hash

g.setColor(0, 0, 0);

g.fillRect(mx + wi + wu, my + hi, wu, fh);

g.fillRect(mx + wi + 3 * wu, my + hi, wu, fh);

g.fillRect(mx + wi, my + hi + 2 * hu, fw, hu);

g.fillRect(mx + wi, my + hi + 4 * hu, fw, hu);

}

int tw = f.stringWidth(top);

int bw = f.stringWidth(bottom);

int tx = (mw - tw)/2 + mx;

int tyo = (hi - fnth) /2;

int ty = my + tyo;

g.drawString(top, tx, ty, Graphics.TOP | Graphics.LEFT);

int bx = (mw - bw)/2 + mx;

int by = (my + mh - hi) + tyo;

g.drawString(bottom, bx, by, Graphics.TOP | Graphics.LEFT);

}

}

}

开发者ID:dimagi,项目名称:commcare-j2me,代码行数:79,

示例29: paint

​点赞 2

import javax.microedition.lcdui.Graphics; //导入方法依赖的package包/类

/**

* Draw the friendly item.

*/

protected void paint(final Graphics g, final int w, final int h) {

int x = H_SPACE;

int y = V_SPACE_HALF;

g.setFont(FONT_TITLE);

g.setColor(VisualStyles.COLOR_FOREGROUND);

for (int i = 0; i < titleLines.size(); i++) {

g.drawString((String) titleLines.elementAt(i), x, y, Graphics.TOP

| Graphics.LEFT);

y += H_FONT_TITLE;

}

// Details text

y += V_SPACE_HALF;

g.setFont(FONT_DETAILS);

for (int i = 0; i < detailsLines.size(); i++) {

g.drawString((String) detailsLines.elementAt(i), x, y, Graphics.TOP

| Graphics.LEFT);

y += H_FONT_DETAILS;

}

// Draw left and right part of the separator, then the score in the middle

final String scoreStr = (link.getScore() > 0 ? "+" : "")

+ link.getScore();

final int scoreHeight = H_FONT_SCORE + SEPARATOR_V_SPACE;

y = height - scoreHeight - V_SPACE_HALF;

g.setColor(VisualStyles.COLOR_FOREGROUND_DIM);

if (separatorImage != null) {

g.drawImage(separatorImage, width / 2, y + scoreHeight / 2,

Graphics.TOP

| Graphics.HCENTER);

}

g.setFont(FONT_SCORE);

g.drawString(scoreStr, width / 2, y - V_SPACE_HALF, Graphics.TOP

| Graphics.HCENTER);

// Draw thumbnail image

if (showImage && link.getImage() != null) {

g.drawImage(link.getImage(), width - H_SPACE, V_SPACE_HALF,

Graphics.TOP | Graphics.RIGHT);

}

}

开发者ID:mozilla,项目名称:pluotsorbet,代码行数:49,

示例30: drawImageCentered

​点赞 1

import javax.microedition.lcdui.Graphics; //导入方法依赖的package包/类

/**

* Draws an image centered to the given rectangular area.

* @param g Graphics context.

* @param img Image to draw.

* @param x X-coordinate.

* @param y Y-coordiante.

* @param maxW Maximum width of image.

* @param maxH Maximum height of image.

*/

public static void drawImageCentered(Graphics g, Image img, int x, int y, int maxW, int maxH){

if (Log.TEST) Log.note("[Util#drawImageCentered]-->");

if (img != null) {

int imgXOff = x + (maxW - img.getWidth()) / 2;

int imgYOff = y + (maxH - img.getHeight()) / 2;

g.drawImage(img, imgXOff, imgYOff, Graphics.TOP | Graphics.LEFT);

}

}

开发者ID:mozilla,项目名称:pluotsorbet,代码行数:18,

注:本文中的javax.microedition.lcdui.Graphics.drawImage方法示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。

表情包
插入表情
评论将由博主筛选后显示,对所有人可见 | 还能输入1000个字符
相关推荐
©️2020 CSDN 皮肤主题: 深蓝海洋 设计师:CSDN官方博客 返回首页