[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]

hey /g/, how would i go about writing every single rgb value

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: 14
Thread images: 6

File: DeahMercColorPalette2[1].jpg (116KB, 1024x512px) Image search: [Google]
DeahMercColorPalette2[1].jpg
116KB, 1024x512px
hey /g/, how would i go about writing every single rgb value in pic related in a text file automatically? is there some format that stores data like this?
>>
array obv
>>
You can write a program to do it very easily.
>>
File: values.jpg (101KB, 1000x445px) Image search: [Google]
values.jpg
101KB, 1000x445px
Well that's a JPEG so you're already fucked.
But if you had it as a lossless file, convert it to a BMP and open the image in a hex editor - pic related.
It's relatively easy to suck the pixel data out of a lossless file. BMP is the easiest imo.
>>
>>52486492
Computers are magic, fucking magic.
>>
>>52486466
>>52486490
>>52486492
This was my first thought, but I cannot code. I might do the BMP thing because I do have the losless file, but then is there a way to convert that hex data into plaintext numbers for RGB automatically?
>>
>>52486555
literally copy and paste and some basic math bro

Convert the original to a BMP and upload it, I'll check it out and hold your hand
>>
>>52486626
dont have it on this pc, but dont worry. you can bet if i have more technical trouble i will be back on /g/ the very next day.

thanks all
>>
File: fag.png (160B, 32x32px) Image search: [Google]
fag.png
160B, 32x32px
>>52486671
well i'll teach you anyway. i made a BMP but i can't upload it so here's a PNG representation of it
>>
>>52486555
import java.awt.image.BufferedImage;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;

import javax.imageio.ImageIO;

public class Main {

public static void main(String[] args) {
BufferedImage img = null;
try {
img = ImageIO.read(new File("input.jpg"));
for (int y = 0; y < img.getHeight(); y++) {
for (int x = 0; x < img.getWidth(); x++) {
int rgb = img.getRGB(x, y);
String outputFile = "output.txt";
FileWriter fw = new FileWriter(outputFile,true);
BufferedWriter bw = new BufferedWriter(fw);
bw.write("#"+Integer.toHexString(rgb).substring(2).toUpperCase()+"\n");
bw.close();
}
}
} catch (IOException e) {
}

}
}


prints in this format
#B8ABB5
#B8ABB5
#B7AAB4
#B7AAB4
#B7AAB4
#B7AAB4
#B7AAB4
>>
>>52486671
>>52486770
next up, open it in a hex editor and find where the pixel data is
In this image it's at 0x36
>>
>>52486786
lastly copy that shit to a text editor and run a script/record a macro where you separate the AB CD EF AB CD EF to:
#ABCDEF
#ABCDEF
etc
>>
>>52486828
Can confirm it is literally this easy, OP. Just in case you though you were somehow being /g/entoo'd on
>>
File: Screenshot_2016-01-18_14-03-00.png (154KB, 1440x900px) Image search: [Google]
Screenshot_2016-01-18_14-03-00.png
154KB, 1440x900px
>>52486422
I wrote pic related program to do that
Here's the code
#include <stdio.h>
int main(int * argc, char * argv[])
{
FILE *in;
in = fopen("out.ppm", "wb");
int r = 0, g = 0,b=0;
fprintf(in, "P6\n5527 3000\n255");
while(r < 256)
{
while(g < 256)
{
while(b < 256)
{
b++;
fputc(r,in);
fputc(g,in);
fputc(b,in);
}
b = 0;
g++;
}
r++;
g = 0;
}
fclose(in);
return 0;
}


Also you should read up on this file format, it is far easy to implement as compared to even BMP
>https://en.wikipedia.org/wiki/Netpbm_format
Thread posts: 14
Thread images: 6


[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.