Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write code in C to apply the following items to each of the files given below: Read a gif file, and store the data into

Write code in C to apply the following items to each of the files given below:

Read a gif file, and store the data into an unsigned char array (unsigned char [4000]) and the data size in an int variable.

Print the width and height, and color table data in the format described below.

Modify the color table based on the rules listed below.

Do #2 again to show the changes

Write the data to a new file.

Must use these functions :

int printinfor(unsigned char []); prints out the required information

int readfile(unsigned char [], int*, char []); reads a gif file and stores data into an array Tip: To read binary data from a file, use the fread() function

int writefile(unsigned char [], int, char []); writes image data from an array into a file Tip: To write binary data to a file, use the fwrite() function

Rules to modify a color table

Apply these rules to each color

By using bitwise operators, check if every RGB value is greater than BF (191 in decimal), but don't use ">", "<", ">=", or "<=".

If it is true, use bitwise operator(s) and divide the RGB values by 2. Don't use "/" or "*".

e.g., F3 will be 79

Otherwise, do the following by bitwise operators (don't use any arithmetic operators such as "+", "-", "++", "--", "*", "/", and "%"):

in the R value, raise the 4 lower bits. (The resulted bits will be XXXX1111 where X represents an unchanged bit)

e.g., 31 will be 3F.

in the G value, flip the second bit. (The resulted bits will be X*XXXXXX where * is the bit to flip)

e.g., 05 will be 45, and F3 will be B3.

in the B value, clear the third and forth bits. (The resulted bits will be XX00XXXX)

e.g., 7A will be 4A.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Advances In Databases And Information Systems 14th East European Conference Adbis 2010 Novi Sad Serbia September 2010 Proceedings Lncs 6295

Authors: Barbara Catania ,Mirjana Ivanovic ,Bernhard Thalheim

2010th Edition

3642155758, 978-3642155758

More Books

Students also viewed these Databases questions

Question

4. Describe cultural differences that influence perception

Answered: 1 week ago