


#Simpleimage class how to
To proceed further it is assumed that you have completed the previous project How to read and write image file in JavaĬode we will use in this project import java.io.File Where, (x,y) is the co-ordinate of the pixel and A, R, G and B denote the Alpha, Red, Green and Blue value of the pixel respectively.Įxample: P 0,0(255,100,150,200) represents a pixel at co-ordinate (0,0) having A = 255, R = 100, G = 150 and B = 200. So, we can denote a pixel (x,y) as P x,y(A,R,G,B) That is the width of the image is 963 pixels and the height of the image is 640 pixels.įor a 2D image we will have pixels arranged in rows and columns. Origin (starting pixel) of the image is at the coordinate (0,0). In the above picture we can see the dimensions as 963圆40. In the following image we get the detail like Type, Dimensions and Size of the Image File.ĭimensions of an image file is generally represented in width x height format. Similarly, (1111 1111) 2 in binary is equal to (FF) 16 in hexadecimal.ĢD images have a width and a height generally denoted in pixels. So, (0000 0000) 2 in binary is equal to (00) 16in hexadecimal. We can also represent the bit values in hexadeimal form. Then converting this value into decimal, we will get (1111 1111) 2 = 255 10 Similarly, if all the 8 bits of ALPHA is set to 1 i.e., 1111 1111. Then converting this value into decimal, we will get (0000 0000) 2 = 0 10 Therefore, if all the 8 bits of ALPHA is set to 0 i.e., 0000 0000. The bit position of the 4 components is summarized in the table belowĮach of these bit position will take any of the two bit values or binary values i.e., 0 or 1.

The first bit is at the rightmost side and is numbered or indexed 0 and the last bit is at the leftmost side and is numbered or indexed 31. Alpha take the leftmost 8 bits while Blue takes the rightmost 8 bits of the pixel. The image shown below represent a single pixel value consisting of 32 bits. And since a pixel has 4 components so, the total number of bits required to store the value of all the four components ARGB is equal to 4x8 = 32 bits or 4 bytes. This means we will need only 8 bits to store the value of any of the four component. So, 8 bits can represent any value in the range 0 to 255. We generally denote these four components as A for Alpha, R for Red, G for Green and B for Blue.Įach of these four components (ARGB) take a value between 0 to 255 both inclusive, where 0 means the component is missing and 255 means the component is fully present. The smallest unit of an image is called a Pixel, and it is generally made up of 4 components namely:Īlpha determines the transparency while Red, Green and Blue determines the color of the pixel. How to get pixel values of an image and how to set pixel value of an image in Java programming language. We will learn how to store pixel value in a variable. In this theory part of the Image Processing Project we will learn about pixels.
