本文整理汇总了Java中javax.microedition.lcdui.Graphics.getClipX方法的典型用法代码示例。如果您正苦于以下问题:Java Graphics.getClipX方法的具体用法?Java Graphics.getClipX怎么用?Java Graphics.getClipX使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.microedition.lcdui.Graphics
的用法示例。
在下文中一共展示了Graphics.getClipX方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: paintVideo
import javax.microedition.lcdui.Graphics; //导入方法依赖的package包/类
/**
* Paint video into canvas - in USE_DIRECT_VIDEO mode
*/
public void paintVideo(Graphics g) {
// Don't paint if Canvas visible flag is false
if (!pvis || !cvis || painting)
return;
painting = true;
// Save the clip region
int cx = g.getClipX();
int cy = g.getClipY();
int cw = g.getClipWidth();
int ch = g.getClipHeight();
// Change the clip to clip the video area
g.clipRect(dx, dy, dw, dh);
// Check if its within the bounds
if (g.getClipWidth() > 0 && g.getClipHeight() > 0 && pvis) {
int w = dw, h = dh;
if (w > videoWidth)
w = videoWidth;
if (h > videoHeight)
h = videoHeight;
try {
if (rgbData != null) {
synchronized (rgbData) {
if (scaled) {
g.drawRGB(scaledData, 0, dw, dx, dy, dw, dh, useAlpha);
} else {
g.drawRGB(rgbData, 0, videoWidth, dx, dy, w, h, useAlpha);
}
}
}
} finally {
// Revert the clip region
g.setClip(cx, cy, cw, ch);
painting = false;
}
} else {
g.setClip(cx, cy, cw, ch);
painting = false;
}
if (TRACE_FRAMERATE) {
if (frameStartTime == 0) {
frameStartTime = System.currentTimeMillis();
} else {
frameCount++;
if ((frameCount % 30) == 0) {
int frameRate = (int) ( (frameCount * 1000) / (System.currentTimeMillis() - frameStartTime + 1));
System.err.println("Frame Rate = " + frameRate);
}
}
}
}