|
-
January 17th, 2013, 04:41 AM
#7
Re: Resizing BMP Files
 Originally Posted by VeNiX
Isn't that a job for the header file to handle? essentially since I say that width is say 6 pixels, the renderer will be expecting a width that is a multiple of 4, so it expects 6 pixels plus 2 pixels of padding, after which it starts rendering the next row anyway... and since I'm already printing the pixels factor * factor of times it should work.
You are not printing pixels factor * factor times. That's why your algorithm doesn't work.
You essentially have:
Code:
for (int i = 0, biHeight = abs(bi.biHeight); i < biHeight; i++)
{
//...
for (int k = 0; k < bi.biWidth; k++)
for (int l = 0; l < factor; l++)
fwrite(&buffer[k], sizeof(RGBTRIPLE), 1, outptr);
So horizontally you print each pixel of the original image 'factor' times, but not vertically.
Maybe you should take a simpler example.
Code:
int original[3][3] = { { 1, 2, 3 }, { 4, 5, 6 }, { 7, 8, 9 } };
const int factor = 2;
int resized[3 * factor][3 * factor] = { 0 };
Copy the values from original to resized in the same way you would do it for an image. You can easily check your results by printing the matrix to the screen.
There are no bytes or padding to worry about here; just the basic algorithm that you need.
Cheers, D Drmmr
Please put [code][/code] tags around your code to preserve indentation and make it more readable.
As long as man ascribes to himself what is merely a posibility, he will not work for the attainment of it. - P. D. Ouspensky
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|