讲解:C:CS104 Bitmap FilesR、R、R

代写C语言基础作业,对Bitmap格式文件进行读写解析操作。IntroductionThe purpose of this lab is to give you some practice using structs and reading binary data from files. To get started, run a git pull in your repository to download the lab 5 starter code.We’ve provided the Makefile for this lab; you shouldn’t need to change it. Simply run make to compile the program.Introduction: Bitmap filesA 24-bit bitmap file is a simple image file format that consists of two main parts:The file metadata.The pixel array, storing numbers corresponding to the blue, green, and red colour values of each pixel in the image (as a number between 0 and 255).(Note: the actual file format consists of an optional third section after the pixel array, but we’ll ignore that section for the purpose of this lab.)At fixed locations in the file metadata, there are three important integers (each stored with exactly 4 bytes):At byte offset 10-13, the offset in the bitmap file where the pixel array starts.At byte offset 18-21, the width of the image, in pixels.At byte offset 22-25, the height of the image, in pixels.Suppose our bitmap image has height m and width n; we’ll always assume in this lab that the width n is a multiple of 4, which simplifies the byte layout in the file a little. For this image, the pixel array stores exactly 3nm bytes, in the following way:Each group of 3 bytes represents a single pixel, where the bytes store the blue, green, and red colour values of the pixel, in that order.Pixels are grouped by row. For example, the first 3n bytes in the pixel array represent the pixels in the top-most row of the image. C代写:CS104 Bitmap Files帮做R编程作业、R作业调试、调试R作业That’s all you need for this lab, but if you’re curious about learning more about the bitmap file format, you can start here.Task 1: Reading bitmap metadataIn the starter code, we have provided a main function in bitmap_printer.c that opens a bitmap file for processing, and a separate file bitmap.c that implements the required functions for working with bitmaps.Your first task is to use the description of the bitmap metadata to implement read_bitmap_metadata. Don’t just try to read in the entire bitmap file! Use fseek to navigate to different byte locations so that you only read in the three required integers.We’ve provided in the starter code two sample bitmap files you can use to test your work. It’s quite possible for you to go out and find your own bitmap images, but beware that there are many variations of this file format, and we’re only covering the 24-bit version in this lab, so you might need to convert new images to this format yourself (and crop to ensure the width is a multiple of 4).Task 2: Reading in pixelsNow, you’ll read in all of the pixels into memory, using a common pattern for storing a two-dimensional array on the heap. Read through the comments in the starter code carefully to complete this part.Note that because each pixel colour value (blue, green, or red) is stored in just one byte, the type we use is unsigned char, which is guaranteed to represent the numbers 0-255.Task 3: Cleaning upDon’t forget about tidying up the program’s resources! Add some code to the bottom of the main function in bitmap_printer.c to close the bitmap file and free all of the program’s dynamically-allocated memory.转自:http://ass.3daixie.com/2019011522881421.html

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • By clicking to agree to this Schedule 2, which is hereby ...
    qaz0622阅读 1,494评论 0 2
  • The Great A.I. Awakening How Google used artificial intel...
    图羽阅读 1,233评论 0 3
  • 2018年7月7日 星期六 农历五月二十四 天气晴 作息:昨晚23:50睡,今早4:50起床 学习:早课徐寿老师《...
    饶爱兰阅读 169评论 0 0
  • 今天合唱比赛的结果出来了,我们成绩不太理想,没取得晋级的资格。说实话这个结果让人听遗憾的,那天我感觉自己唱的还是不...
    孙庚启阅读 247评论 1 8
  • 1.早知道很多人走散就不会再见 就该说出那句吞回肚里的话 给出本该给予的拥抱 2.早知道老同学很难再聚 寝室熄灯后...
    搬砖少女樱阅读 644评论 0 0