Questions tagged [resize]

resize.c, one of the assignments in Problem Set 4, will require you to scale a bitmap image by a certain factor (making it 2, 3, or n times as large).

Filter by
Sorted by
Tagged with
9
votes
1answer
4k views

How to Update bfSize in resize?

In resize problem, we have to update the headers of image. Which attributes should be updated and how do i update bfSize attribute?
8
votes
2answers
2k views

How does fread progress through each byte in copy.c?

In copy.c (and the other apps using the same start code), how does freed know to read one byte after another? It seems to just do it automatically. Eg, this will read each byte, from first until bi....
7
votes
1answer
2k views

Hacker4/Resize: can't resize when factor is a decimal number

Everything went good so far until this pset and the resize exercise, it seems that I'm stuck and need help! Everything works perfectly when the factor is a whole number (eg. 2). In my code, the ...
4
votes
2answers
287 views

PSET4 resize more: Check50 indicates 3 errors (1x1px to 3x3 - 5x5 px)

I'm now doing the pset4 resize more version as I have already done the 'less version' with successfull check50. For my 'more version' check50 indicates 3 errors although visually my outputs look good....
3
votes
1answer
1k views

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

I am working on resize.c, and I was wondering why when you set the new dimensions for the bitmap, the width and height in the code are written as bi.biWidth and bi.biHeight. i.e. why do you write: (...
3
votes
1answer
942 views

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

BITMAPFILEHEADER new_bf; BITMAPINFOHEADER new_bi; new_bf = bf; new_bi = bi; new_bi.biHeight = bi.biHeight*factor; new_bi.biWidth = bi.biWidth*factor; int padding = (4 - (bi.biWidth * sizeof(...
3
votes
1answer
1k views

pset 5 resize vertically - use of fseek

I am struggling with the vertical resizing using the recopy approach. I read a pseudocode in an answer to another question in this forum and am trying to code it. I feel I am near but something is not ...
3
votes
1answer
561 views

what is fseek() exactly doing?

I'm stuck since a while in the 'resize' task. Don't fully get my head around the padding. // read scanline pixel/pixel from infile // write pixels to outfile // skip padding // add padding back ...
2
votes
1answer
4k views

Pset4 resize.c - bfsize & bisizeimage formulas

First of all thanks for your time. Taking cs50 through edX - struggling as all alone here and videos / lectures are burnt out for information - need real people! Online cs50 really does assume a lot ...
2
votes
1answer
2k views

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

I'm currently working on the cs50 pset4. My question is pretty straight forward: How does the line (marked with caps lock comment) "RGBTRIPLE triple;" knows whicht pixel currently to store? I get the ...
2
votes
2answers
4k views

Pset 5 - Resize

I'm having problems with the header manipulation. My code seems to factor well images but it doesn't calculate well bi.biSizeImage and bf.bfSize. This is what I've done: // read infile's ...
2
votes
1answer
1k views

pset4 resize - fseek help (I think)

I'm on the verge of giving up. I've been stuck on this problem for weeks. I managed the headers, and I think I set up the loops right to write the pixels correctly. I just can't wrap my head around ...
2
votes
2answers
1k views

Why abs(bi.biHeight)?

I have written pset4's resize.c and it took me a while to find the bug in my code. All I want to ask is what is the difference between bi.biHeight and abs(bi.biHeight)? With bi.biHeight some cases ...
2
votes
1answer
181 views

Memory leak in Pset4

According to valgrind I have a memory leak in my version of resize. Here's the valgrind output: ==22900== Memcheck, a memory error detector ==22900== Copyright (C) 2002-2013, and GNU GPL'd, by ...
2
votes
1answer
2k views

Resize's Padding Issue

My resize for pset4 finally worked and I can resize the small.bmp (that green square) properly. however it doesn't work for all the check50 requirements(except for compiling and running) and i don't ...
2
votes
2answers
168 views

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

I can get smiley.bmp and large.bmp to scale properly, but not small.bmp, where the former is 3x3 and the latter two are larger (exactly how much larger I don't know) -- so I assume my program only ...
2
votes
1answer
819 views

How does copy.c know which RGBTRIPLE it is supposed to copy?

I don't understand how the program knows where in the infile it is. I am imagining a sort of cursor that automatically moves to the end of what has been read by fread (is this correct?). How does ...
2
votes
1answer
1k views

resize in pset4 - can't figure it out

I have been stuck on the resize pset for a few days now. I have looked at all questions on here and reddit but just can't figure it out. When I do the peek, the headers seem consistent with the staff ...
2
votes
1answer
928 views

pset4 : How does the xxd command work?

Specifically, could someone explain what the flags used with the commands are? In the pset4 specs at one point it is mentioned that they use a different value for -c depending upon the number of ...
2
votes
1answer
94 views

Pset 3: Resize gives me green vertical strip and black vertical strip

Apologies that I cannot be more specific here, I've been through my code with the debugger multiple times and have reviewed other examples online but I'm stuck on PSET3 resize. I think I'm saving ...
2
votes
1answer
543 views

pset4 resize doesn't resize

I have been looking for answers here but wasn't able to make the code work, so I am hoping someone will be able to help with this question. I have been working on pset4 resize for several days now and ...
2
votes
1answer
95 views

Why should we assume that the size of the output BMP file does not exceed 4 GB?

Per the spec of pset5, You’re welcome to get started by copying (yet again) copy.c and naming the copy resize.c. But spend some time thinking about what it means to resize a BMP. (You may ...
2
votes
1answer
178 views

Header Problem in Resize

There is some serious flaw in the header file code of my program since all the variables that was required to be modified is showing error while running the peek program (as shown in in the screenshot ...
1
vote
1answer
1k views

pset4 resize, invalid or unsupported image format

I've looked up previous questions and seen people have also tended to change bfSize as well, but when I did this the image was still unsupported so I changed it back. As such nothing in ...
1
vote
2answers
155 views

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

I managed to complete the pset4/resize, but am having difficulty understanding the concept behind how it works. That gap is showing up in my attempt at pset4/jpg. fread as far as I know doesn't tell ...
1
vote
1answer
5k views

Pset4, resize, padding

i've been struggling with this for days now. Could someone plz point out what i am doing wrong? It resizes pictures without padding properly, but despite introducing new_padding for resized picture, ...
1
vote
1answer
779 views

BITMAPFILEHEADER bf in resize.c

typedef struct { WORD bfType; DWORD bfSize; WORD bfReserved1; WORD bfReserved2; DWORD bfOffBits; } __attribute__((__packed__)) BITMAPFILEHEADER; And then in the resize.c: BITMAPFILEHEADER ...
1
vote
1answer
426 views

Pset4 Resize.c Array Overstepping

I have been stuck on resize for a while. I am currently struggling on the vertical portion of resize. I am using the "rewrite" method as explained in the problem spec. My program does resize an image ...
1
vote
1answer
298 views

pset4: resize - bmp looks good in xxd, won't pass check50

I am so close to completing resize.c here. The resulting bitmaps look perfect in both xxd and when viewed in Image Viewer. However, the program does not pass any check50 requirements aside from the ...
1
vote
4answers
1k views

check50 gives confusing results for pset4 resize

FOR CS50 STAFF ACTION: When I ran check50 against resize, I got a very confusing result. I've seen that others have seen the exact same result. Here's the problem - the output is giving negative ...
1
vote
2answers
572 views

How to create a BMP image that is compatible with resize?

Using my resize on small.bmp and smiley.bmp then with cs50's peek, I get the exact same values as with the staff's solution for BITMAPFILEHEADER and BITMAPINFOHEADER (I tested with different n values)....
1
vote
1answer
1k views

check50 reports resize as incorrect for 1, 2, 3, 5 for seemingly correct code

is the check50 report for my code : jharvard@appliance (~/Dropbox/pset5/bmp): check50 2014/x/pset5/resize bmp.h resize.c :) resize.c and bmp.h exist :) resize.c compiles :( doesn't resize 1x1-pixel ...
1
vote
1answer
2k views

resize: having header problems

My program compiles and everything, but when I try to open up the image it says the image has "bogus header files". I'm not sure what I'm doing wrong. Here's some of my code: // read infile's ...
1
vote
1answer
245 views

what is happening in pset5 resize hacker edition?

I implemented the staff's solution to compress a bmp by a factor say 0.5 and compared the compressed version with the original bmp using xxd command. I expected it copy just half of rgb triples from ...
1
vote
1answer
871 views

Choosing pixels in resize (More)

I figured that in order to resize an image using a float for the scale factor I could pick the pixels to copy from the source image's scanlines as follows: For example, if the source image is 3px ...
1
vote
1answer
149 views

How do I tell what offset outptr points to?

I think I'm having trouble pointing to the correct places using fseek although I can't tell for certain since I don't know where outptr points to.
1
vote
1answer
201 views

Is my pset5 resize working or not?

When I try to run my ./resize 4 small.bmp large.bmp I get this: jharvard@appliance (~/Dropbox/pset5/bmp): ./resize 4 small.bmp large.bmp Could not open 4. Check50 seems to say that I have extraneous ...
1
vote
1answer
126 views

Pset3 - Resize (less confortable)

I am getting an error at IDE "Invalid or unsupported file format" for an input "n" equal or greater than: 68 for small.bmp 36 for smiley.bmp 27 for large.bmp I also tried to peek with staff's ...
1
vote
1answer
310 views

Problem Set 3 (Resize) Help

I have been working for a while now, and I have a few questions regarding the Resize problem set. My code makes sense to me intuitively, but I am sure I went wrong somewhere, as my output is clearly ...
1
vote
1answer
932 views

PSET 4 - resize.c less

This is my code: // Resizes a BMP file pixel by pixel, given a factor n #include <stdio.h> #include <stdlib.h> #include "bmp.h" int main(int argc, char *argv[]) { // ensure proper ...
1
vote
1answer
63 views

Could someone please tell me where I'm going wrong here in resize-less(pset4)?

#include <stdio.h> #include <stdlib.h> #include <string.h> #include "bmp.h" int main(int argc, char *argv[]) { // ensure proper usage if (argc != 4) { fprintf(stderr, "Usage: ...
1
vote
1answer
112 views

Resize Invalid Image Format

For the past couple of days, I have been struggling with Resize (less comfortable). I have looked at similar questions and I've been able to fix some problems yet my largest one remains the same: my ...
1
vote
1answer
418 views

Problem with horizontal resizing Pset4 resize

I'm working on Pset 4 re-size. I've got the header files working correctly (as tested by using the "peek" function, and by using a factor of 1 - my programme creates perfect copies of any of the .bmp ...
1
vote
1answer
105 views

pset4 resize file header question

I'm struggling a bit with pset4 changing the header info. I feel like in principle I know what I'm supposed to do but struggling a bit with syntax/pointers? Following the resize walkthrough, I know ...
1
vote
1answer
118 views

pset4/resize. problem with resize code and i don't know what to do

I am trying to solve resize but I am facing problems and I don't know what to do. I don't even know is the problem with my info update or with fseek. I feel that there is something I miss or don't ...
1
vote
1answer
66 views

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

I used my implementation of 'resize.c' to recreate 'large.bmp' in a file called 'test.bmp' using 'small.bmp'. I used ./resize 4 small.bmp test.bmp. It looks as it should when viewed, but then I tried ...
1
vote
1answer
911 views

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

I am trying to solve pset4/resize.c using the recopy method (i.e. allocating memory and using a buffer to write the line to it and then repeat it). However the final picture only shows black with a ...
1
vote
1answer
136 views

Stuck at resize.c

int pastwidth = bi.biWidth; int pastHeight = bi.biHeight; int padding = (4 - (SCALE * sizeof(RGBTRIPLE)) % 4) % 4; bi.biWidth = SCALE; bi.biHeight = SCALE; bi.biSizeImage = ((SCALE+padding*SCALE+...
1
vote
2answers
114 views

Pset4 8x8 smiley only showing 7x7

I thought that my resize.c was not resizing correctly. I enlarged the original small.bmp 3x3 by factor of 2 into large.bmp, but the resized image would only show (on screen) 5x5 instead of 6x6, which ...
1
vote
1answer
417 views

pset4 resize.c - general struggles

I'm mentally blocked and I was wondering if anyone would take a look at my code and give me a pedagogical clue? I am struggling to get the correct colour output in my resized.bmp; there have been ...

1
2 3 4 5
13