10 votes
Accepted

How does “RGBTRIPLE triple;” know whitch pixel to store?

You have mixed them a little in your head but we are here. :) Firstly, the line RGBTRIPLE triple; doesn't get a pixel, it just declares a variable, of type RGBTRIPLE with the name triple. It would ...
ChrisG's user avatar
  • 7,396
10 votes
Accepted

pset4: resize.c - why is biWidth written as bi.biWidth

Welcome to the wonderful world of structures! ;-) A structure, or a struct, is a collection of individual vars combined into a group. The group has a variable name, and each element in the struct has ...
Cliff B's user avatar
  • 68.8k
8 votes
Accepted

pset4 resize, invalid or unsupported image format

The immediate problem lies with your header structures. You have created bi_new and modified two of it's fields, but you forgot to copy the contents of bi to bi_new, so all of the unmodified fields ...
Cliff B's user avatar
  • 68.8k
5 votes
Accepted

Memory leak in Pset4

Actually, your apparent problem is that you are running valgrind against a different executable binary, also called resize. ~/workspace/ $ which resize /usr/bin/resize ~/workspace/ $ whatis resize ...
hotwebmatter's user avatar
  • 3,050
5 votes
Accepted

pset4 resize.c negation of 12 cannot be represented in type unsigned long

fseek() accepts a long int as the second parameter and via arithmetic conversion you're passing unsigned long as a second argument. Cast it to long int by inserting (long int) right after the minus ...
Yuri Laguardia's user avatar
4 votes

Resize: Vertical resizing and padding

newBi.biSizeImage is wrong. Can you see why? You are writing wrong stuff in the header with fwrite() too. Prob stuff coming from copy.c. Lastly, you need to understand how the file pointer works. If ...
André Queiroz's user avatar
4 votes
Accepted

pset4 runtime error: unsigned integer overflow

You are subtracting from bi.biWidth on line 125. Since bi.biWidth is an unsigned long, it cannot contain negative values (-1 and so on), instead it's capacity to store positive values is doubled. So ...
kluvin's user avatar
  • 1,223
4 votes
Accepted

Pset4 Resize.c Array Overstepping

After edit: For reference, here is the pseudocode from the walkthrough: for each row       for each pixel          ...
DinoCoderSaurus's user avatar
4 votes
Accepted

BITMAPFILEHEADER bf in resize.c

I'm assuming that you are asking why the typedef in bmp.h works. If not, please clarify your question, and I'll update the answer. In bmp.h: typedef struct { WORD bfType; DWORD bfSize; ...
robert_x44's user avatar
3 votes
Accepted

Pset4 Resize : Compiles but gives error :File size exceeded when I run resize

You have an infinite loop in the third for loop. for(int l = 0; i < n; l++) See anything wrong with the test condition???? If this answers your question, please click on the check mark to accept....
Cliff B's user avatar
  • 68.8k
3 votes

Error in my pset4 resize.c code

The width of your image is 3. When you use that minus sign here fseek(inptr, -bi.biWidth * sizeof(RGBTRIPLE), SEEK_CUR); , it becomes -3. But before the multiplication takes place, C rules of ...
Yuri Laguardia's user avatar
3 votes

in pset4, resize: How does the structs declared in 'bmp.h' know which bytes to get the data from?

How does the structs declared in 'bmp.h' know which bytes to get the data from? The resize program works with the BMP file format which has a few characteristics which need to be altered, namely ...
Tarmyniatur's user avatar
3 votes

Choosing pixels in resize (More)

I'm dealing with that at the moment, and as far as I can tell the form is newArray[i] = oldArray[(int)floor(i / factor)] Then, if factor = 0.5 floor(0/0.5) = 0 /* newArray[0] = oldArray[0] */ floor(...
bluesmonk's user avatar
  • 131
3 votes
Accepted

PSET4 resize (less) check50 error

Well, your description is sort of right. The image size is incorrect. When I ran the code, the headers are fine. The problem is that the image data that's being generated is too large by roughly ...
Cliff B's user avatar
  • 68.8k
3 votes
Accepted

I can't figure out the problem in my resize (more) code

That line seems to be the culprit: for (int i = 0; i < f * outbi.biHeight; i++) Would have to use abs(outbi.biHeight) or equivalently (int) (f * HeightIn), not f * outbi.biHeight. The line fseek(...
Blauelf's user avatar
  • 20.9k
2 votes

Pset4 8x8 smiley only showing 7x7

I realise that this question is over a year old, however other people may still be having the issue so thought I would answer. I have had exactly the same issue - for me, the problem was caused by ...
SumatranHamster's user avatar
2 votes
Accepted

Pset4 resize: Everything should be working, but it doesn´t

Actually, your output file is not identical to the input file. It's missing two pixels (6 bytes) from the last row in the file. It isn't sufficient to look at the image or just the header values. You ...
Cliff B's user avatar
  • 68.8k
2 votes
Accepted

pset4 Resize adding padding... and resize in general (HELP ME!)

Your code has a number of problems. Based on what you have said, and what is in the code, I think you'd benefit more from some guidance on how to work through this pset and some general advice. When ...
Cliff B's user avatar
  • 68.8k
2 votes
Accepted

pset4 Resize: Don't understand problems with size and dimensions

You have two problems, one with the header and one with image processing. In the header, you have calculated all the values correctly. (BTW, that was the most unique way I've seen to date to add the ...
Cliff B's user avatar
  • 68.8k
2 votes
Accepted

Resize: color randomization

Very common problem. You have only calculated the padding for the input file, but not the putput file. The padding for the output file will be dependent on the scaling and other factors. You need to ...
Cliff B's user avatar
  • 68.8k
2 votes
Accepted

Pset4 - resize : stuck in resizing vertically (Yes, i have read other q&a regarding this topic, but still can't figure out the solution)

fseek(inptr, 0 - padding_ori - horiz, SEEK_CUR); Interesting way to do this. When the loop finishes, isn't horiz equal to bi.biWidth? Now, when you call fseek(), what units does it use to move? ...
Cliff B's user avatar
  • 68.8k
2 votes
Accepted

Resize problem(File indicator pointer)

You are almost there, but one piece is still missing. I'll assume that when your resize factor is 1, it works fine. (If not, you need to fix that first.) When you are processing a resize (n) greater ...
Cliff B's user avatar
  • 68.8k
2 votes
Accepted

Why is resize not passing check 50?

You are very close to the solution. The headers are all correct, but there's an issue with the image area. You need to take a close look at the image data itself and compare it to the staff solution. ...
Cliff B's user avatar
  • 68.8k
2 votes
Accepted

pset4: File operations using fwrite(arguments)

The reason is that the third parameter is NOT the number of times to write out the contents of buffer. It's the number of ELEMENTS, the second parameter (the size of an element) to be written. For ...
Cliff B's user avatar
  • 68.8k
2 votes
Accepted

Stuck at resize.c

I think you need to spend some time to go back and review the pset instructions, shorts videos and class material before refining your code. While doing so, here are some suggestions. Headers: While ...
Cliff B's user avatar
  • 68.8k
2 votes
Accepted

PSet4, resize.c. Stuck on solution using malloc (recopy)

Your code is fixable with 3 adjustments. The biggest problem is that your "tracker variable" (t) for your buffer gets reset to 0 for every pixel of the infile, rather than for every line. In other ...
Omid's user avatar
  • 36
2 votes
Accepted

Resize is not passing check50, but still properly scaling larger images

Your mistake is that you don't add the needed padding for each line that you write to the output file. Inside your outer for loop (the one with the o), right after the ending of the second for loop (...
ChrisG's user avatar
  • 7,396
2 votes
Accepted

Pset4, original large.bmp weird thing I noticed while looking to the raw bytes of the file

biSizeImage Specifies the size, in bytes, of the image. This can be set to 0 for uncompressed RGB bitmaps. source: MSDN So it's the size in bytes, not pixels. An hence 144*3 == 432 (since each ...
ChrisG's user avatar
  • 7,396
2 votes
Accepted

Trouble with padding in resize

Two small problems with significant impact. First, the code calculates the output padding before calculating the output file width. This is disrupting the size of the output padding and two header ...
Cliff B's user avatar
  • 68.8k
2 votes
Accepted

getting runtime error: unsigned integer overflow

About the overflow, read this: Error in my pset4 resize.c code Apart from that, what's happening is that you're copying the headers to bi and bf, but you're not copying those headers also to bfNew ...
Yuri Laguardia's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible