Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Pixelization

Name: Anonymous 2010-11-20 15:09

What's wrong with this fucking code. I have a fever and my brain is in full retard mode.
http://pastebin.com/825hz7zh

Trying to create a pixelization method.

Basically.. input parameters are x and y coordinates for the upper left corner of the rectangle selection to be pixelated, and it's height and width.

numPixels is is the size of each "big pixel" the method will create.

The idea is to loop through each pixel inside the rectangle, add up the color values for each pixel in red/blue/green variables, while having a counter counting all pixels, when the counter%numPixels==0, the average of all colors in that "square" will be stored in an color array, and a counter keeping track of the colors will be incremented.

Then the color variables are reset and the color for next big pixel is calculated etc.

Then it's supposed to loop through all pixels again, and set the color for all pixels inside big pixel 1 to colorx[0], all pixels inside big pixel 2 to colorx[1] etc..

Right now it doesn't seem to be working at all, for some x,y values it ..almost works, and creates one big pixel. And for some it doesn't seem to do anything at all.

http://u.snelhest.org/i/2010/11/20_9143.png < this is what i'm trying to achieve

Name: Anonymous 2010-11-20 20:23

>>1
That's not what I told you on /g/! You were supposed to loop through each big pixel separately.
public void f(int recx, int recy, int width, int hight, int blursize)
{
    int pixels_x = ceiling(width/blursize),
        pixels_y = ceiling(hight/blursize); /* your a fag for saying "hight" btw */

    for (int i = 0; i < pixels_x; ++i)
        for (int j = 0; j < pixels_y; ++j)
        {
            int r = 0, g = 0, b = 0, n = 0;
            for (int x = recx + i * blursize; x < recx + (i + 1) * blursize && x < recx + width; ++x)
            for (int y = recy + j * blursize; y < recy + (j + 1) * blursize && y < recj + higth; ++y)
                /* rgb += pixel, n += 1 */
            Color c = /* rgb/n */
            /* now iterate again, but instead this.setpixel or w/e */
        }
}


And I can't be bothered to check why your code doesn't work, I don't do Java.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List