Using a hex editor to edit an image We can actually use hex editors to change image files Usually, we will use programs like PhotoPlus or PhotoShop But.

Slides:



Advertisements
Similar presentations
Creating a Customized List of Classes Using Microsoft Access 2000® Stephen J. Woods Idaho State University.
Advertisements

Internet Services and Web Authoring (CSET 226) Lecture # 5 HyperText Markup Language (HTML) 1.
KompoZer. This is what KompoZer will look like with a blank document open. As you can see, there are a lot of icons for beginning users. But don't be.
Computer Science 101 Picture Files. Computer Representation of Pictures Common representation is as a bitmap. Common representation is as a bitmap. Two.
Digital Color 24-bit Color Indexed Color Image file compression
XHTML Basics.
1 Pengantar Teknologi Internet W03: CSS Cascading Style Sheets.
Web Pages and Style Sheets Bert Wachsmuth. HTML versus XHTML XHTML is a stricter version of HTML: HTML + stricter rules = XHTML. XHTML Rule violations:
1 3 Computing System Fundamentals 3.5 Data Representation.
Sixteen Squared. 256 One Squared 1 Three Cubed.
Multiplication Facts 9 through x 5= 50 Number One.
Data Representation COE 202 Digital Logic Design Dr. Aiman El-Maleh
Presentation Title Your Name Organisation and Telephone Number.
Intermediate Level Course. Text Format The text styles, bold, italics, underlining, superscript and subscript, can be easily added to selected text. Text.
Tutorial 4: Designing a Web Page with Tables
Creating a centre square design in Photoshop 1.Skills and techniques overviewSkills and techniques overview 2.Steps 1–8: the first segmentSteps 1–8: the.
Bit Depth and Spatial Resolution SIMG-201 Survey of Imaging Science © 2002 CIS/RIT.
HTML Lesson 2 TBE 540 Farah Fisher. Prerequisites Access web pages and navigate Use search engines to locate specific information Download graphics from.
Writing programs which create image files. We have seen that an image file just contains a sequence of bytes –We know, in detail, the rules that apply.
Graphics File Formats. 2 Graphics Data n Vector data –Lines –Polygons –Curves n Bitmap data –Array of pixels –Numerical values corresponding to gray-
XP Creating Web Pages with HTML Using Tables. XP Objectives Create a text table Create a table using the,, and tags Create table headers and captions.
A 24-bit depth.bmp file made in XVI32 This 2-by-2 image was handcrafted in XVI32 Bytes 1C-1D hex in the Info Header say that the image uses 24-bit (18.
Using HTML Tables.
A bug in PhotoPlus When PhotoPlus X2, version , is used to create a new.bmp file, it does not create the Pixel Data correctly This bug may have.
How pictures are stored in computers. While it is useful to know how to use picture editing software, Computer Scientists should understand how pictures.
How Images are Represented Bitmap images (Dots used to draw the image) Monochrome images 8 bit grey scale images 24 bit colour Colour lookup tables Vector.
Lesson Objectives Explain the representation of an image as a series of pixels represented in binary Explain the need for meta data to be included in the.
An Introduction to Scanning and Storing Photographs and Graphics Bryn Jones Aug 2002
The following slide has the same photo at three resolutions. Each version has been resized in Powerpoint to occupy the entire width of the screen. Remember.
Basic HTML The Magic Of Web Pages. Create an HTML folder  Make a folder in your H drive and name it “HTML”. We will save EVERYTHING for this unit here.
Internet Skills An Introduction to HTML Alan Noble Room 504 Tel: (44562 internal)
Working with Numbers in Alice - Converting to integers and to strings - Rounding numbers. - Truncating Numbers Samantha Huerta under the direction of Professor.
CO1552 – Web Application Development Lists, Special Characters, and Tables.
© GCSE Computing Candidates should be able to:  explain the representation of an image as a series of pixels represented in binary  explain the need.
Amber Annett David Bell October 13 th, What will happen What is this business about personal web pages? Designated location of your own web page.
Adding Content to the Agency Web Site - Part 2. Adding individual web pages for success stories Agency Web Site Adding Content 2, Slide 2Copyright © 2004,
Department of Information Technology Chapter 8 - Creating Hypertext links Lecturer: Ms Melinda Chung.
10/4/2015Tables1 Spring, 2008 Modified by Linda Kenney 4/2/08.
Microsoft Expression Web-Illustrated Unit I: Working with Tables.
Copyrighted material John Tullis 10/17/2015 page 1 04/15/00 XML Part 3 John Tullis DePaul Instructor
Checkout Options Tour Unlock the “POWER” of V7.2 To navigate through this Tutorial use your mouse, or Page Up or Down Key Introduction Slide One.
CIS234A- Lecture 7 Instructor Greg D’Andrea. Tables A table can be displayed on a Web page either in a text or graphical format. A text table: – contains.
Manipulating images in Art and Design Nicola Gardiner Prospect College 2004.
Binary, Hexadecimal, Decimal, and How They Relate.
 To begin you first need to sign up to Weebly by going to or alternatively and we will create an account.
Bitmap images Resizing bitmaps Vector images Why are there so many image file formats? Resolution and Scanning “Bits” and.bmp files Photo editors JPG file.
NUMBERS Arda Işık Emir Ceylan Elif Başkoca Göksu Türkmen
Digital Images are represented by manipulating this…
Resolution The resolution of an image is determined by the number of individually addressable points that make up the image, whether it is the number.
Division By Mr. English Gold Ridge Elementary School Folsom, California.
Spiderman ©Marvel Comics Creating Web Pages (part 1)
Graphics and Image Data Representations 1. Q1 How images are represented in a computer system? 2.
What do you think this lesson is all about? Write your answer on a sticky note.
Microsoft PowerPoint™ 2010
CSS Layouts CH 13.
Numbers Let's recap !.
Add a subtitle if necessary
Reading Netpbm Images.
What time is it? or What’s the time?.
We count one, two, three….
GRAPHICS Source:
Data Representation.
Creating a Customized List of Classes Using Microsoft Access 2000®
Representing Images 2.6 – Data Representation.
What do these words mean to you?
Numbers
Numbers and Number Names 0-20
Look at the clock. Thirteen One Fourteen Two Fifteen Three Sixteen
STRIKE THE NUMBER! PLAY.
MATHS TIME! nine ten eleven fifteen eight
Presentation transcript:

Using a hex editor to edit an image We can actually use hex editors to change image files Usually, we will use programs like PhotoPlus or PhotoShop But if you use a hex editor, you will appreciate the fundamental details of how images are stored in files We will change test.bmp using XVI32 First, however, we must learn some details of the.bmp format

The.bmp format A file in the Microsoft.bmp format can also be known as a.dib file A detailed description can be found here and The first of these is a local copy of this Microsoft page:

The.bmp format A.bmp file file has four sections The File Header contains general details about the file The Info Header contains general details about the image in the file The Colour Table describes the palette of colours used in the image The Pixel Data specifies the contents of the dots in the picture by specifying, for each pixel, which colour in the palette is used in the pixel

The.bmp format

File test.bmp

The first two bytes of the File Header contain the ASCII codes for BM, as specified

File test.bmp Bytes three to six of the File Header contain hex This number is in little-endian format, so it is really hex This is equal to 1094 dec We saw earlier that this is, indeed, the size of the file

File test.bmp Bytes eleven to fourteen of the File Header contain hex This number is in little- endian format, so it is really hex

File test.bmp Bytes eleven to fourteen of the File Header contain hex This number is in little- endian format, so it is really hex This number points to the start of the pixel data in the file

File test.bmp Bytes one to four of the Info Header contain hex This number is in little- endian format, so it is really hex As the format specifies, this is equal to 40 dec

File test.bmp Bytes five to eight of the Info Header contain hex This number is in little- endian format, so it is really hex This is, indeed, equal to the width of the picture in test.bmp, which is 4px wide by 4 px high

File test.bmp Bytes nine to twelve of the Info Header contain hex This number is in little- endian format, so it is really hex This is, indeed, equal to the height of the picture in test.bmp, which is 4px wide by 4 px high

File test.bmp Bytes thirteen to fourteen of the Info Header contain hex This number is in little- endian format, so it is really hex This is, indeed, equal to the number 1 which is specified in the format

File test.bmp Bytes fifteen to sixteen of the Info Header contain hex This number is in little- endian format, so it is really hex So 8 bits are used to represent each pixel, allowing for a palette which contains 256 different colours Even though only 2 colours are used in the picture

File test.bmp Bytes seventeen to twenty of the Info Header contain hex So the picture is not compressed

File test.bmp Bytes twenty-one to twenty-four of the Info Header contain hex This number is in little- endian format, so it is really hex Since the image is not compressed, this value seems to be irrelevant

File test.bmp Bytes twenty-five to twenty-eight of the Info Header contain 12 0B hex This number is in little- endian format, so it is really B 12 hex This specifies 2834 dec pixels per metre horizontally

File test.bmp Bytes twenty-five to twenty-eight of the Info Header contain 12 0B hex This number is in little- endian format, so it is really B 12 hex This specifies 2834 dec pixels per metre horizontally This agrees with the fact that PhotoPlus says that 4 pixels equals centimetres

File test.bmp Similarly, bytes twenty- nine to thirty-two of the Info Header contain 12 0B hex This number is in little- endian format, so it is really B 12 hex Again, this specifies 2834 dec pixels per metre horizontally Which agrees with the fact that PhotoPlus says that 4 pixels equals centimetres

File test.bmp Bytes thirty-three to thirty-six of the Info Header contain hex Since this is in little- endian, it is really hex This means that there are 256 dec colours in the palette

File test.bmp Bytes thirty-three to thirty-six of the Info Header contain hex Since this is in little- endian, it is really hex This means that there are 256 dec colours in the palette Since there are 4 bytes per colour, the palette should occupy hex bytes Which it does, ranging from 0036 to 0435

File test.bmp Bytes thirty-seven to forty of the Info Header contain hex Since this is in little- endian, it is really hex This means that there are only 2 important colours in the palette Which agrees with what we know -- the picture contains only blue and red pixels

File test.bmp Bytes one to four of Colour Table are FF 00 The fourth byte is unused FF 00, so ignore it Since the three bytes FF are little-endian, they are really FF These represent proportions of RGB (Red, Green, Blue) Thus, the first colour in the palette consists of 255 red 0 green 0 blue That is, the first colour in the palette is pure red

File test.bmp Bytes five to eight of the Colour Table contain FF Since the three bytes FF are little- endian, they are really FF Thus, the second colour in the palette consists of 0 red 0 green 255 blue That is, the first colour in the palette is pure blue

File test.bmp Before we look at the pixel data in the file, let's look at the image and zoom in to see it clearly

File test.bmp In the Pixel Data, the bottom row is stored first, the pixel details being given in the order left-to-right These four pixels are specified to use colour 01 in the colour table, that is the second colour, that is pure blue

File test.bmp The second row from the bottom is stored next, the pixels again in left-to- right order These four pixels are specified to use colour 00 in the colour table, that is the first colour, that is pure red

File test.bmp The third row from the bottom is stored next, the pixels again in left-to- right order These four pixels are specified to use colour 01 in the colour table, that is the second colour, that is pure blue

File test.bmp The top row is stored last, the pixels again in left-to-right order These four pixels are specified to use colour 00 in the colour table, that is the first colour, that is pure red

Changing test.bmp Let's use XVI32 to change the last byte in the file, changing it from 00 to 01 This byte represents the right-most pixel in the top row of the picture We have changed its value, making it refer to the second colour in the Colour Table, which is pure blue Let's store the modified picture in a file called test2.bmp

File test2.bmp When we open test2.bmp in PhotoPlus, we see that we have, indeed, made the change we intended The right-most pixel in the top row of the picture has been changed to blue

Storing the test.bmp image more efficiently Re-open the original test.bmp We can store its image more efficiently, by reducing the Colour Table to contain just the two colours that are used If we use XVI32 to make the appropriate changes, we get the bytes shown below -- now only 78 dec bytes are needed Let's store the modified data in a file called test3.bmp

Viewing image in test3.bmp When we open test3.bmp in PhotoPlus, we see that the image in the 78-byte file looks exactly like the image in the 1094-byte file

Changing the aspect ratio of the image We can easily convert the image in test3.bmp into an 8-by-2 image instead of a 4-by-4. because both images contain 16 bytes In XVI32, we need change only the two bytes highlighted below Let's store the modified data in a file called test4.bmp

Viewing image in test4.bmp The image has two rows, each eight pixels long

Lines must be padded out to multiples of 4 bytes Below is a file containing a 5-by-3 image, a 15-pixel image Although the image has one pixel less than the previous image, the file is larger - it contains 86 bytes instead of 78 This is because, although each line has only 5 pixels, each line must be padded out to a multiple of 4 bytes, so 8 bytes are needed for each line Below, the padding bytes are coloured light blue - zeros are used for padding here, but it appears that the padding can be anything Let's store this 15-pixel image in a file called test15d.bmp

Viewing image in test15d.bmp The image has three rows, each five pixels long As we see on next slide, the pixels are as we would predict from XVI32

Viewing image in test15d.bmp The pixels are as we would predict from XVI32 –Remember that the pixels of the top row appear last in the file –Remember that colours are represented as Blue-Green-Red-unused

A bug in PhotoPlus As we shall see later, there is a bug in the way that PhotoPlus handles.bmp files So, first, let's check that the view which PhotoPlus gives of the image in test15d.bmp is correct We will look at the image in another image editor and in some browsers

Viewing image in test15d.bmp in MS Paint The View menu has been tuned to 800% so that we can see detail The image looks the same as we expect

Viewing image in test15d.bmp in Firefox The View menu has been used to zoom in so that we can see detail The image looks the same as we expect

Viewing image in test15d.bmp in Opera The View menu has been used to zoom in so that we can see detail The image looks the same as we expect

Viewing image in test15d.bmp in MSIE Internet Explorer does not display.bmp files itself Instead, it calls MS Paint as a helper program As we have already seen, in MS Paint the image looks as expected

Absolutely basic 8-bit depth.bmp format We have seen that the common image display programs ignore much of the format for 8-bit-depth.bmp files The minimum we must do when making an 8-bit depth file is –assign the fixed values shown below to the bytes marked green –put the image width and depth in bytes hex and hex, respectively –specify the number of colours in bytes 2E-31 hex –specify the colours in 4-byte blocks from byte 36 hex onwards (two colours are shown in the example below) –specify the pixels immediately afterwards, padding the lines if necessary (16 pixels are shown in the example below) –put the address of the first pixel specification in bytes 0A-0D hex –put the overall file size in bytes hex