void sepia(int height, int width, RGBTRIPLE image[height][width])
{
RGBTRIPLE pixel;
BYTE red, green, blue, sepiaRed, sepiaGreen, sepiaBlue;
double d_sepiaRed, d_sepiaGreen, d_sepiaBlue;
for ( int i = 0; i < height; i++)
{
for (int j = 0; j < width; j++)
{
pixel = image [i][j];
red = pixel.rgbtRed;
green = pixel.rgbtGreen;
blue = pixel.rgbtBlue;
d_sepiaRed = round(red * 0.393 + green * 0.769 + blue * 0.189);
d_sepiaGreen = round(red * 0.349 + green * 0.686 + blue * 0.168);
d_sepiaBlue = round(red * 0.272 + green * 0.534 + blue * 0.131);
if( d_sepiaRed > 0xFF)
{
sepiaRed = 0xFF;
}
else
sepiaRed = (BYTE) d_sepiaRed;
if( d_sepiaGreen > 0xFF)
{
sepiaGreen = 0xFF;
}
else
sepiaGreen = (BYTE) d_sepiaGreen;
sepiaBlue = (BYTE) d_sepiaBlue;
image[i][j].rgbtRed = sepiaRed;
image[i][j].rgbtGreen = sepiaGreen;
image[i][j].rgbtBlue = sepiaBlue;
}
}
}```
```// Convert image to grayscale
void grayscale(int height, int width, RGBTRIPLE image[height][width])
{
WORD word_average;
BYTE average;
RGBTRIPLE pixel;
for ( int i = 0; i < height; i++)
{
for ( int j = 0; j < width; j++ )
{
pixel = image[i][j];
word_average = ((WORD) pixel.rgbtBlue + pixel.rgbtGreen + pixel.rgbtRed) / 3;
if (word_average > 0xFF)
{
average = 0xFF;
}
else
average = (BYTE) word_average;
image[i][j].rgbtBlue = average;
image[i][j].rgbtGreen = average;
image[i][j].rgbtRed = average;
}
}
}```
#Rob asked me to showcase of what I have cooked
23 messages · Page 1 of 1 (latest)
Any reason to use BYTE and WORD in there?
now I see that I have made a mistake converting
Very cool!!!
Yea cool indeed
here
lol u deserved it tbh
Tho what are the bytes used for @hexed egret
Just for seeing who has the most ?
BYTE and WORD were already defined uint8-t and uint16_t its smaller then int
and i did this acrobatics to handle overflow
Yes but why not just use the uints
valid
so why tf no t
I was googling what kind of data type round() returns and it didnt give me an answer then I googled how much of number of a type float is the exponent, and it was 8bits which wouldnt help me and then I made a mistake and compiler told me that return type is double >:) and I learn a lot ^^
double it and give it to the next
wait I can Byte farm this way? D:
Haha, I see what you did there, }{at! 😉 Byte farming is definitely a thing around here. It's a fun way to engage with the server.