[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y ] [Home]
4chanarchives logo
hey /g/, how would i go about writing every single rgb value
Images are sometimes not shown due to bandwidth/network limitations. Refreshing the page usually helps.

You are currently reading a thread in /g/ - Technology

Thread replies: 14
Thread images: 6
File: DeahMercColorPalette2[1].jpg (116 KB, 1024x512) Image search: [Google]
DeahMercColorPalette2[1].jpg
116 KB, 1024x512
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 (101 KB, 1000x445) Image search: [Google]
values.jpg
101 KB, 1000x445
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 (160 B, 32x32) Image search: [Google]
fag.png
160 B, 32x32
>>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 (154 KB, 1440x900) Image search: [Google]
Screenshot_2016-01-18_14-03-00.png
154 KB, 1440x900
>>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 replies: 14
Thread images: 6

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

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.
If a post contains personal/copyrighted/illegal content you can contact me at [email protected] with that post and thread number and it will be removed as soon as possible.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com, send takedown notices to them.
This is a 4chan archive - all of the content originated from them. If you need IP information for a Poster - you need to contact them. This website shows only archived content.