8.13 - Reading a binay file (2 - GIF)

Objetive

Create a C# program to check if a GIF image file seems to be correct.

It must see if the first four bytes are G, I, F, 8.

In case it seems correct, it must also display the GIF version (87 or 89), checking if the following byte is a 7 or a 9.


Solution

using System;
using System.IO;

public class GifFile
{

    public static void Main() 
    {    
        byte[] data = new byte[5];
        BinaryReader myFile;
            
        myFile = new BinaryReader(
            File.Open("example.gif", FileMode.Open));
        
  for (int i=0; i<5 data-blogger-escaped-a="" data-blogger-escaped-be="" data-blogger-escaped-console.writeline="" data-blogger-escaped-convert.tobyte="" data-blogger-escaped-data="" data-blogger-escaped-does="" data-blogger-escaped-else="" data-blogger-escaped-file="" data-blogger-escaped-gif8="" data-blogger-escaped-gif="" data-blogger-escaped-i="" data-blogger-escaped-if="" data-blogger-escaped-myfile.close="" data-blogger-escaped-myfile.readbyte="" data-blogger-escaped-not="" data-blogger-escaped-pre="" data-blogger-escaped-seem="" data-blogger-escaped-seems="" data-blogger-escaped-t="" data-blogger-escaped-to="">

Popular Posts