skmezanul / microemu

Automatically exported from code.google.com/p/microemu
0 stars 1 forks source link

drawRGB graphics translations are ommited #57

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Get or create the test midlet.
2. Past this method to your MIDlet class:

    protected void startApp() throws MIDletStateChangeException {
        Canvas canvas = new Canvas() {
            int rectW = 50;
            int rectH = 50;
            int[] rgbaRectData;

            private void initRGBData(int w, int h, int color) {
                rgbaRectData = new int[rectW * rectH];
                for (int n = 0; n < rgbaRectData.length; ++n) {
                    rgbaRectData[n] = color;
                }
            }

            protected void paint(Graphics g) {
                renderTestImages(g);
            }

            private void renderTestImages(Graphics g) {
                // preparing screen
                g.setClip(0, 0, getWidth(), getHeight());
                g.setColor(0);
                g.fillRect(0, 0, getWidth(), getHeight());
                // center
                drawRect(g);
                // center left-top
                g.translate(rectW, rectH);
                drawRect(g);
                g.translate(-rectW, -rectH);
                // center right-bottom
                g.translate(-rectW, -rectH);
                drawRect(g);
                g.translate(rectW, rectH);
                // center left-bottom
                g.translate(-rectW, rectH);
                drawRect(g);
                g.translate(rectW, -rectH);
                // center right-top
                g.translate(rectW, -rectH);
                drawRect(g);
                g.translate(-rectW, rectH);
            }

            private void drawRect(Graphics g) {
                int rectLeft = (getWidth() - rectW) / 2;
                int rectTop  = (getHeight() - rectH) / 2;
                g.drawRGB(rgbaRectData, 0, rectW,
                          rectLeft,
                          rectTop,
                          rectW, rectH, true);
            }

            protected void keyPressed(int keyCode) {
                rectW += 10;
                rectH += 10;
                initRGBData(rectW, rectH, 0x7FFFFF00);
                repaint();
                serviceRepaints();
            }

            public void setFullScreenMode(boolean mode) {
                initRGBData(rectW, rectH, 0x7FFFFF00);
                super.setFullScreenMode(mode);
            }
        };

        canvas.setFullScreenMode(true);
        Display.getDisplay(this).setCurrent(canvas);

        destroyApp(true);
    }

3. Press "any key" to observe (repeat third step several time to have 
interesting visual bugs) :)

What is the expected output? What do you see instead?
see the result on WTK emulator (or other one). I used WTK 2.5.2.

What version of the product are you using? On what operating system?
microemulator version 3.0.0-SNAPSHOT.75.

Please provide any additional information below.
Operating system - Fedora 11.

The problem in Graphics.drawRGB method. It doesn't take into account graphics 
translations (g.getTranslateX(), g.getTranslateY()).

Original issue reported on code.google.com by mightysk...@gmail.com on 18 Jun 2010 at 7:21