Domanda

Ho le seguenti funzioni:

private void clearScreen(int color)
{
    fOffscreenImage.eraseColor(color);
}

private void fillRect(int x, int y, int width, int height, int color)
{
    for(;x<width;x++)
    {
        for(;y<height;y++)
        {
            buffer[x+y*PROJECTIONPLANEWIDTH] = color;
        }
    }
}

private void drawBuffer()
{
    fOffscreenImage.setPixels(buffer,0,PROJECTIONPLANEWIDTH,0,0,PROJECTIONPLANEWIDTH,PROJECTIONPLANEHEIGHT);
}

Entrambe le funzioni di disegno in bitmap, in primo luogo è da eraseColor, che funziona bene, e il secondo è di setPixels, che restituisce sempre nero. Sto scrivendo l'immagine su un quad visualizzato con OpenGL. Come input colore ho cercato colori predefiniti (Color.Blue) e Color.argb. getPixel fa restituire la corretta uscita dei colori in questione.

Una chiamata da pixel per setPixel non funzionerebbe neanche, sarebbe ignorare il lavoro.

Sono provato con Android 2.1 e 2.3.

Tutti i suggerimenti su questo sarebbe grande ..

È stato utile?

Soluzione 3

private void fillRect(int x, int y, int width, int height, int color)
{
    width += x;
    height += y;
    for(;x<width;x++)
    {
        for(;y<height;y++)
        {
            buffer[x+y*PROJECTIONPLANEWIDTH] = color;
        }
    }
}

dovrebbe essere

private void fillRect(int x, int y, int width, int height, int color)
{
    width += x;
    height += y;
    for(int y2 = y;y2<height;y2++)
    {
        for(int x2 = x;x2<width;x2++)
        {
            buffer[x2+y2*PROJECTIONPLANEWIDTH] = color;
        }
    }
}

Altri suggerimenti

I sostituito parte del raycaster con il seguente codice fillRect, e si vede linee bianche sui luoghi appropriati ora! Ora solo per scoprire altri colori così:)

private void fillRect(int x, int y, int width, int height, int color)
{
    width += x;
    height += y;
    for(;x<width;x++)
    {
        for(;y<height;y++)
        {
            if (x+y*PROJECTIONPLANEWIDTH < PROJECTIONPLANEHEIGHT*PROJECTIONPLANEWIDTH)
                buffer[x+y*PROJECTIONPLANEWIDTH] = color;
        }
    }
}

Ho fissato questo non usando un setPixel, ma usando invece di lavoro per disegnare la bitmap. Tuttavia è morto lento ..

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top