So now it's time to create I'm fed inside this colorful class.
So before the ending curly brace of these colorful class here I'm gonna say public so the access modifier
of this method is public.
Now I need to specify the return type of this method.
The return type of this method is going to be bitmap.
Write the name of this if it is going to be colorize colorize the beath map.
OK so let's actually to change it to return return the colorize colorized bitmap because if it is you
need to return a value of a bitmap.
It's better to name it in this way.
Return the colorized bitmap.
So just put a pair of parenthesis.
If it is going to it's not going to accept any parameters.
So just open and close this method by using this curly braces.
Let's say this.
And let's see what you are going to do next.
So first of all let me tell you that we actually created an instance variable inside our colorful class.
Here it is in line number 13 you can see that we have an instance variable which is of type bitmap and
this is private.
The name is bitmap right.
Let's scroll down here.
Inside this method because this method is going to actually return a value of type bitmap.
I am going to manipulate my instance variable which is of type bitmap so I'm going to actually first
of all I'm going to get the width of the bitmap so I'm going to say eat wheat or bitmap.
Actually bitmap
assignment operator bitmap dots.
Get with a semicolon right.
Let's now actually get the height of that bitmap so it bitmap height bitmap height assignment operator
base map that gets height.
Let me introduce just they've been bitmap that gets height semi-colon.
Right now I have the V and the height of my bitmap instance variable.
So let's actually go in.
Let's actually add some more logic here.
Now it's time to get the formats of the bitmap.
It is called conflict so I'm going to say bitmap data can't feek it is of type that can't be right.
This is the type right the name is going to be bitmap config assignment operator.
Now I'm going to refer to my instance variable which is called bitmap that gets conferee semicolon is
going to get convicted if it is going it's going to ask to return the format of the bitmap.
Now I'm going to create an order object of type bitmap and I'm going to assign it to another variable
so let me show you how we can do that.
So we're going to say bitmap that the data type up my body but that they are going to create the name
of my value but is going to be my bitmap my bitmap assignment operator.
Now because this is actually a local variable Let's actually change it to local bitmapped local bitmap
because it is only alive inside the curly braces of this math right.
Right.
So it is called the local local bitmap.
Now I'm going to say bitmapped that creates bitmap this it is going to actually create a bit map for
us.
First we need to specify the bitmap which.
So if we have that bitmap it will come up bitmap height color.
And finally we need to pass the bitmap config bitmap conflict in this way.
We actually created an object of type bitmap we divied height and the conferee of the bitmap of the
instance valuable here.
And we as scientists created objects to this local bitmap valuable.
Right now let's see what we are going to do next.
So as you may already know and a picture consists of pixels.
Right.
So I'm going to actually get each pixel inside my image by using a for loop and an inner for loop.
Let me show you how we can do that.
Let me show you how we can actually iterate over the pixels of an image.
So I'm going to say for so first we need to specify the initial value.
So and row assignment operator 0 right semi-colon.
Now I'm going to specify the condition that specifies how many times this for loop is going to be executed
until the show is less than the value of this bitmap.
With bitmap with semi-colon.
And finally I'm going to say that after each execution of this for loop we're going to add one value
to the value of this row valuable row plus plus.
Let's open and closed this for a loop by using these curly braces.
So here I am iterating over each pixel in one in one row.
So I'm going to create another for loop and say this for a loop sign when I say for NKT column assignment
operator zero semicolon.
So this is the initial value.
So what is the condition the condition is until Cullom is less than bitmapped height semi-colon column
plus plus that's it.
Let's open and closed this for loop by using these curly braces.
Now inside this for loop I can't say.
So what does this mean.
This for a loop.
This means that you're either reading over each column of each row.
Right.
In this way if you are iterating over each pixel of our image our piece not actually right.
So let's go inside this for loop and here inside the curly braces of this inner loop I can say here
we can get the color of each pixel how we can do that.
So create and it is a variable and the name of this variable is going to be pixel color write assignment
operator here I'm going to refer to my instance variable which is called bitmaps I'm going to say bitmap
dot get pixel bitmap that get pixel.
Now we need to pass the row and the color.
So we have the ROW comma column semicolon in the way it's going to get each pixel.
Of our image and it's going to assign that value which is going to be a colored value right.
And it's going to assign it to this value of a pixel color.
It's going to get the color of each pixel and it's going to assign to this variable pixel color right.
So after this line of code let's be fair because we want to actually change the color of each pixel
of our image.
I'm going to again refer to this pixel color assignment operator and I'm going to use this MFL color
with capital C. OK color dot R G B.
Use this method.
So let's look at this if it is if it needs four arguments the first one is going to be the alpha.
The second argument is going to be the color red.
The first argument is going to be the color green and the fourth argument is going to be the color blue.
So first we need to specify the Alfar of the pixel color.
So here I can say that again the first of these color class with capital C dot Alpha.
And here we need to pass an argument which is going to be half integer.
And as you can see its name is color so this color is referring to the pixel color right.
I'm going to get the same Alfar of my pixel color that we have inside our bitmapped the same alpha.
So peaks color or just pass the piece of color here.
So now I need to specify the color red.
So not is that inside this for loop inside this inner fall.
Actually we are changing or we are.
In other words we are colorizing each pixel inside our Peetz map right.
So you may notice that if we have some instance variables that may show this instance variables for
the red colored value green color value and blue color value.
So these instance variables these values are going to impact the color of each pixel right.
This is the goal of this class actually.
So here for the red color I'm going to say red color value multiplied by.
So I'm going to multiply this value by the value of the red color actually so color does red with actually
lowercase are color that red and this it needs an argument of type integer which is going to be the
pixel color because I want to change the color of each piece so I'm going to pass pixel color right.
So now it's actually showing us an error if we hovered over this area.
It says that it's going to actually give us a value of type float because the lead color value is actually
a float and the result of this operation here is going to be a value of a flawed color that red here
is actually of that integer and this value is a float.
The result of this operation is going to be flawed so we need to cast this red colored value to an integer
value.
How we can't do that.
So before this varicolored value after the comma I want to put a pair of practices and instead of parenthesis
just type in it that's it.
Now the error is gone.
So let's specify the other arguments.
So after this second argument which is going to be space which is going to specify the red color comma
and now I need to specify the color green.
So again I'm going to say green color green color value right.
Which is of type float multiplied by colored dots.
Green and when we need to pass the piece of color here because we want to actually to change the pixel
color right the color of each pixel if you want to colorized it.
So we are using this green color value in order to impact each pixel and we are multiplying these two
values to get there.
So again it is flawed.
We need to actually cast it to an integer value.
So just pull a pair of Prentice's instead Apprentice's just open here and that's it.
Now it's time to specify the final argument which is going to be the blue color.
So again blue color value multiplied by color that blue Apprentice's I can easily refer to this pixel
color.
So again it is of type float.
This blue color values of the float indicated an integer value.
So just put up for Apprentice's here before its name.
And just like in here.
Now it is tested to an integer value and the result of this operation is going to be half that integer
so that we have no problems passing this argument at the end of your statement.
We must put a semicolon.
So let me try to create a new line here so that you can see these values better.
So you can see all these values here.
First we are specifying the color Alfar by using that piece of color alpha here then we are specifying
the actual red color.
So notice that here when I say color that Alpha we want to specify to actually take Alpher of the pixel
color which is going to be the same Alpher of the bitmap image that is going to be taken by the user
by using the camera.
So and then we need to specify the red color value.
So if you want to colorize each pixel here and then that green color value and that and in blue color
value so that you can actually later see how we can colorize our image.
Hopefully it does make sense and if it doesn't make sense don't worry you can actually push the discussion
in the course and all you can always out this tutorial over and over again until it makes sense.
And it's not that hard.
It's so simple.
But make sure to ask questions.
If you if you've got any questions please post or discussion it of course.
So now here now that we actually colorize each pixel now it's time to look at our local bitmap my valuable
here.
We created this valuable inline number 95.
So after colorizing each pixel here I'm going to say look Quilpie is map dot said Peaks of local bitmap
that said pixel.
And now first of all we need to specify the actually read and then for the second argument we need to
specify the height.
And finally you need to specify that pixel color right.
The color of each pixel.
So we have that beat right.
I can't say bitmap with comma bitmap height comma.
Finally we have the pixel color that sits and because the return type of this method is actually bitmap.
We must return a value of type bitmap so I'm going to return this local bitmap from this method.
So after the end in curly brace of this for a loop here and before the end in curly brace of the Smurfette
I'm going to just re type in here.
Return local bitmap semicolon.
So that's it.
Now we have no errors here.
This is our method.
Now it's time to use this method.
It's time to go to the main activity class and use this method.
So it and I thought you we're going to do that.