Thread: Read bmp

  1. #1
    Registered User
    Join Date
    Jun 2020
    Posts
    1

    Post Read bmp

    HELLO,
    i need to Extract the thermal height from the map "XC.bmp" (Maximum map size 800x800 pixels can be assumed - the map size will change and read from the file).
    and create a "therm_res.txt" coordinate file with their location and updated heights .
    each pixel on the map represents 100 meters**



    Blue
    131
    93
    51
    125
    255
    255
    189
    189
    113
    Green
    255
    215
    138
    93
    134
    213
    153
    98
    70
    Red
    177
    93
    53
    51
    52
    129
    165
    199
    119
    Height
    2700
    2400
    2100
    1800
    1500
    1200
    900
    600
    300


    How should I move from here?

    Code:
    #include <stdio.h>
    #include <math.h>
    #include<Windows.h>
    
    
    int read_bmp() {
    	unsigned int size = 0;
    	int i;
    	FILE * picXC;
    	fopen_s(&picXC, "XC.bmp", "rb");
    	if (!picXC) {
    		printf("Problem reading XC.bmp file\problems with setting heights");
    	}
    	else for (i = 0; i<4; i++) size |= fgetc(picXC) << (i * 8);
    	// read into "therm_res.txt" 
    	fclose(picXC);
    	return 0;
    }
    Attached Files Attached Files
    Last edited by Salem; 06-16-2020 at 09:36 AM. Reason: Inlined the code

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    I guess you read this, and figure out what all the bytes mean.
    BMP file format - Wikipedia

    Start by trying to print the width and height of a range of bmp files.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 3
    Last Post: 10-28-2015, 02:07 PM
  2. Replies: 2
    Last Post: 12-07-2014, 07:01 AM
  3. Is possible read text form keyboard using read() function?
    By Vanhapolle in forum C Programming
    Replies: 3
    Last Post: 12-08-2013, 11:51 PM
  4. Replies: 7
    Last Post: 12-07-2012, 10:44 PM
  5. blocked on read/recv / how to read/send proper buffers
    By fudgecode in forum Networking/Device Communication
    Replies: 1
    Last Post: 11-02-2010, 11:42 PM

Tags for this Thread