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 ...
3
votes
Accepted
what's the purpose of fseek in PSET4?
First the padding. Keep in mind that the input file and the output file may or may not require the same amount of padding. In item 5, you don't examine the padding in the input file, you skip over it ...
2
votes
Accepted
PSet4 / Resize / Less: When to put the pointer back to the beginning?
In the first case, you want to wind back for all but the last iteration.
In the second case, you would need a different condition, as you want to revert to the beginning of the line in all but the ...
2
votes
Accepted
How to use fseek along side arrays? Pset4 recover
for(int i = 0; i < MEMORYBLOCK; i++)
{
//read & store 512bytes in memory[i]
fread(&(store[i]), 1, 1, inptr); //do we need *inptr instead?
}
If you want to ...
2
votes
Accepted
pset4/resize. problem with resize code and i don't know what to do
Well, you seem to be almost there, so I won't review all of your code, just give you some pointers:
The first and most crucial tip is that you need to pass fseek() the number of BYTES as the second ...
1
vote
Accepted
pset6 server2 load() fseek() return -1 [SOLVED]
First, I love cacahuetes.
Second:
I can tell you one problem right away. This part won't work with pipe streams like php files:
if (fseek(file, 0 , SEEK_END) != 0) {
DBG_Print("\n%i\n", ...
1
vote
Pset4 odd behavior
First... you're using bi.biHeight directly here, but you're forgetting that it is a negative value. I won't say much more... think about that.
bi.biSizeImage = ((bi.biWidth + padding) * bi.biHeight)...
1
vote
Accepted
pset4 resize fseek() - non proper work
You could use
fseek(inptr, -bi.biWidth * sizeof(RGBTRIPLE), SEEK_CUR);
(no padding, as you never read some) to go back to the start of the line where you fseek at the moment, and after that loop, ...
1
vote
Accepted
pset4 Resize - Trouble Understanding Padding
According to MSDN
biSizeImage
The size, in bytes, of the image. This may be set to zero for BI_RGB bitmaps.
If biCompression is BI_JPEG or BI_PNG,
biSizeImage indicates the size of the JPEG or PNG ...
1
vote
Accepted
Understanding padding and fseek()
While we think of an image as pixels and lines, i.e., a two dimensional array like a checkerboard, the data is stored in the file as a single linear string of data. Adding the padding all at once ...
1
vote
Accepted
Pset4 resize less comfortable, problems with fseek
Your guess is pretty good. Look at the following line:
// reset stream pointer for next scanline
fseek(inptr, -((biOut.biWidth * sizeof(RGBTRIPLE)) + outPadding), SEEK_CUR);
First, this ...
1
vote
Accepted
CS50 Pset4 Resize - Vertical Sizing
Have you looked at the raw image data using xxd? The image data for anything larger than n=1 is far too much! The code is using the output file's biHeight and biWidth to control reading the input ...
1
vote
Accepted
Pset 4 Resize fseek()?
Too many one letter variables for me to really understand your code. But reset probably should not include intpadding.
And the j++ within the innermost loop also is quite odd.
1
vote
Accepted
fseek doesent do what i expected
by
fseek(inptr, (sizeof(RGBTRIPLE) * or_Width) + or_padding, SEEK_SET);
you move cursor back to the very beginning of the file (SEEK_SET), and then move it to the beginning of the next row (sizeof(...
1
vote
Accepted
Vertical resizing with fseeks()
Not only with fseek. In the beginning you redefine bi.biWidth and bi.biHeight - now its new width and new height. But when you iterate over scanlines and pixels, you want to do it over infile's ones, ...
1
vote
Accepted
pset 4: resize adding in black pixels
fseek(inptr, bf.bfOffBits + ((oldWidth * 3) * i) + newPadding, SEEK_SET);
You want to go to the start of i line of infile. Each infile line is (oldWidth * 3 + oldPadding) bytes. Multiply it by i and ...
1
vote
CS50 pset4 recover: buffer type and fseek questions
an int is 4 bytes an unsigned char is 1 byte so buffer[3] in char is the 4th byte but in int it is the 13-16 bytes. so when using int you are not actually checking the first 4 bytes, but the first 16.
1
vote
Pset 4 Resize makes a very colorful picture (not green!)--padding problem?
You change bi.biWidth and bi.biHeight to new scale using
bi.biWidth = bi.biWidth * enlarge;
bi.biHeight = bi.biHeight * enlarge;
and then use code that relies on the values to represent the ...
1
vote
Accepted
pset6 load - why does fseek(file, 0, SEEK_END); size = ftell(file); not work?
I'll quote some useful answers, because this question has been asked before:
First Kareem Zidade on a post on facebook:
You'll learn more about that in the following few weeks of the course,
but ...
Only top scored, non community-wiki answers of a minimum length are eligible