/script>
[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

I'm attempting to fill individual pixels of an image in

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 11
Thread images: 1

File: checkerboard.png (13KB, 897x497px) Image search: [Google]
checkerboard.png
13KB, 897x497px
I'm attempting to fill individual pixels of an image in a checkerboard pattern.
No matter what I do, it fails to work. My logic is wrong somewhere.
Anyone willing to take a look?

        public void checkerFilter() {

int r = 0;
int g = 102;
int b = 0;
int x = 0, y = 0;
int col = (r << 16) | (g << 8) | b;

for (int i = 0; i < img.getHeight(); i++) {
for (int j = 0; j < img.getWidth(); j++) {

if (x == img.getWidth()) {
x = 1;
break;
} else if (x == img.getWidth() - 1) {
x = 0;
} else {
img.setRGB(x, y, col);
x += 2;
}
}

y++
img.setRGB(x, y, col);

}

displayImage(); //displays image in jframe

}
>>
>>57447416
forgot to mention I'm working in Java.
>>
>>57447419
>working in Java
there's your problem
>>
>>57447416
you gotta learn from the pros then
shadertoy.com
>>
Does it just not work, or are you not getting the output you expect. Also, >>/dpt/.
>>
Why are you even bothering with x and y?
Just run through j by twos starting at i % 2.
>>
Dont fall for the java meme folks.
>>
>>57447416
What the fuck how can someone be this dumb not being able to draw a simple checkerboard, this surely is some troll?
>>
>>57447934
This.
>>
>>57447934
I think he wants to regard the the checkerboard problem after he finishes drawing it by using those two variables with the interface.
>>
>>57447416
>asking for the solution of a logical problem in programming instead of solving it
dude, this is the funniest part
Thread posts: 11
Thread images: 1


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties.
Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.