Hot answers tagged

7

That is because biHeight in this case is a negative number, and the representation in binary is made by the two's complement in this case, this can be a bit confusing but you can take a look at the link if you are interested. As example the number -3, the one you are expecting, represented as a signed 32-bit integer in binary is: 11111111 11111111 11111111 ...


7

From this really long answer: Using extern is only of relevance when the program you're building consists of multiple source files linked together, where some of the variables defined, for example, in source file file1.c need to be referenced in other source files, such as file2.c. Best way to declare and define global variables Although ...


4

In your example, bf and bi are pointers to two different structures that hold several variables each. These commands will actually write out the indicated full header structures out to the files. Let's walk through one of them: // write outfile's BITMAPFILEHEADER fwrite(&bf, sizeof(BITMAPFILEHEADER), 1, outptr); This command says to write out to the ...


3

From MSDN, biHeight The height of the bitmap, in pixels. If biHeight is positive, the bitmap is a bottom-up DIB and its origin is the lower-left corner. If biHeight is negative, the bitmap is a top-down DIB and its origin is the upper-left corner. The value fffffffd (hex) is 1111 1111 1111 1111 1111 1111 1111 1101 (bin). The two's complement for that ...


2

Your problem is with the new_bf.bfSize. It holds the size of the whole bmp file, not just the headers and the image as you imply, but also the offset from the beginning of the BITMAPFILEHEADER structure to the bitmap bits (per the official microsoft's documentation here: https://msdn.microsoft.com/en-us/library/windows/desktop/dd183374(v=vs.85).aspx).Instead ...


1

I'd like to see what came before this code. Before you did the freads to load the new headers, did you reset the file pointer to the beginning of the file? If not, then it isn't reading the headers. Instead, it is reading image data into the headers. In other words, the new headers are filled with garbage data. You need to either reset the position of the ...


1

This is not true, we can use structures without using that header file. It is possible that your source code specifically needs that file, but not in general. If we write: #include "structs.h" Means that the given file is in the same directory as the source code. If we write: #include <structs.h> The header file is usually located in a special ...


1

I'm a little hesitant to offer any advice because I'm not so excellent at this stuff myself, but you're already making mistakes in your new header data calculations - that's certainly whats indicated by the comparison between your result and the staff result when you checked with peek. Maybe re-watch the walk-through with Zamyla. She pretty much gives you ...


1

It is difficult to respond in a simple way, without going into great depths we can find very good documentation in man pages: We can find documentation of the standard head files by typing in the terminal info stdio or man stdio for example. With non-standard files like cs50.h this does not work, but we can find all the header files in the path /...


1

You'd have to copy the other fields from bi to bi_new. Easiest way is to initialize bi_new using BITMAPINFOHEADER bi_new = bi; which copies the whole structure, you'd still have to change the fields related to the size. Same applies to bf_new, which should be initialized to bf. Your calculation for biSizeImage looks a bit off. It should be the number of ...


1

Maybe you should initialize bf_resize and bi_resize to copies of bf and bi (they should be the same except for four size-related fields), using for example BITMAPFILEHEADER bf_resize = bf; BITMAPINFOHEADER bi_resize = bi; I also see a problem with bi_resize.biSizeImage=((bi_resize.biWidth*sizeof(RGBTRIPLE)+padding2)*(abs(bi_resize.biHeight)*sizeof(...


1

You are correctly reading the BITMAPFILEHEADER and BITMAPINFOHEADER from the file. You are also correctly creating the new ones for the output file, and you correctly change the values you have to change. But you don't copy all the other values from the *HEADERs you read. That's why you get the "bogus header data" message.


1

I solved the cs50.h problem by updating my appliance. For updating open the terminal in the appliance and type-- update50 After the process is completed, cs50.h will work..


1

You appear to be doing it in a wrong way. quote.php, sell.php, buy.php, etc are the controllers themselves. You probably should receive input using the forms, do all the work you need (e.g., validating input, querying the database, etc) in the controllers and deliver the results to the views to be be rendered (if needed) or maybe redirect to another page. ...


1

the answer is wrong, please change it. see below for the correct file1.c from the really long answer: #include "file3.h" /* Declaration made available here */ #include "prog1.h" /* Function declarations */ /* Variable defined here */ int global_variable = 37; /* Definition checked against declaration */ int increment(void) { return global_variable++; ...


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