And we have a WHILE loop here as you can see it says void or the value of this half height variable
as you can see inside of this if statement.
It actually created two other local variables.
Final INT half white.
So this is this is actually a constant.
OK.
And it actually divided the value of this height constant by 2 and then assign that value to these half
height are constant and then it did the same job for this half year half with assignment operator.
We divide it by two.
OK.
And here it says if half height divided by sample size as you can see here is greater than the equator.
And we have an and logical operator here half Viets divided by in sample size is greater than required
V.
Then it's going to actually multiply the value of this in sample size by 2 and then it's going to assign
that value again to this in sample size here.
So this line of code is actually the same as this line of code that I am going to write here.
In sample size assignment operator in sample size multiplied by two.
OK.
So let me ask you to comment on this line of code here.
And as you can see here it's going to return in sample size for us.
OK.
So what this value would be the proper sample size for our image.
Okay.
And if this effort doesn't make any sense to you.
OK.
Don't forget you don't have to know whether these calculations but I know that this is going to actually
give us the proper sample size that we can use on our image.
OK so that application doesn't crash and we have another method in Android documentation as you can
see here.
We have this before.
And it says to use this method first decode with in just decode bounds set to true past the options
for loop and then decode again using the new in sample size value and in just D-CT band for us.
OK so what is this.
In just the code bounds we have it actually introduced us this introduced this variable to us here.
As you can see sitting there in just a decode decode Pound's property to True.
While decoding our memory allocation returning NULL.
OK so it is not going to actually assign that image to the image view.
If you actually assigned a value to do this are valuable for the bitmap object but setting out with
and outside and out out my type so if this is the type of OUR image and here it says that we have this
method here.
OK.
So let's actually copy this method here.
OK.
And let's actually go to our project and it's actually paste this method here and we have this method
here.
OK public static bitmap code sample to bitmap from the source.
Ok so it is going to actually decode the images that are inside of our resources here.
As you can see and here we have a reference to our resources as we have the rest ID of the ID of our
resources.
We have required reach and we have required it.
OK.
And here as you can see inside of this method first the code fit it in just de-code bands PETROU to
check dimensions.
So if you want to check the dimensions of your images set this value at this value but to true.
OK.
Final bitmap factory that options options new bitmapped fact that option.
So you actually created an options object as you can see here but effectively that options and it said
this in just the quarter bounce to true.
It actually called this instance variable on this object.
Okay.
And then we have the speed map factor the class that decoder ring resource.
So as you can see here it refers to this list of resources as you can see that we have as an argument.
OK.
Bitmapped fact is that the court that the court resource rests and we have this idea and we have all
these options.
OK.
So on here as you can see it says calculate in sample size.
So options that in sample size.
Here it is actually calling the Smurfette that we actually pasted here.
As you can see here calculate in sample size.
So branchial it in sample size options.
So as you can see the refers to the options object as you can see here required read and be quite tight.
Okay so it is going to calculate the sample size according to our images for us and we have these options
object that in just in just D-CT bounds two files so D-CT bitmap with sample size set.
So as you can see here it says I said this these in sample size value to false so that we can actually
output that image to the screen Okay.
And here it is returned.
We need to actually return an object of type bitmap as you can see here returned to our factory D-CT
resource raise.
So as you can see here it refers to these less resources less I.D. and options.
OK.
Now let's actually go back to our view method and here is actually typed in our EMG animal data sets.
Image set image bitmap as you can see here.
And here we need to actually put in an object of type bitmap OK.
So here I'm just going to as you can see here it is Meffert as you can see it's going to return an object
of type bitmap.
So if we can i should call this Mfat here.
As you can see in some of these practices.
So the name of this method is the code sample sample bitmap from B source.
So I can just type in de-code sampled bitmapped from the source and this is going to actually accept
some arguments.
OK.
So the resources is context.
OK.
That's good resources.
So it's going to actually get the resources of our project here we need to put into the idea of our
images inside of our application inside our project.
So the idea is animal images supposition as you can see here we have these animal images and we can
actually refers to these ideas in these images by just typing animal images up position.
So as you can see here you have these opposition as an argument.
OK.
So if we could just refer to the name of that position here and here let's actually create a newline
character so that you can see these values better.
And he had as he conceived of you need to actually specify the required and required height.
OK.
As you can see and so it is customized to this view.
Here are the lay out feet and the length height of our image is 100.
So here inside of these Prentice's I can assign the value of 50 comma 50 for the length width and height
and now are actually on our project and see what happens.
So as you can see here now our application is actually running on the simulator.
And now you can see that we can actually scroll and we can see these images here.
OK.
And now our application actually doesn't crash.
OK it's not actually taking too much memory.
Ok but if your device has a very low memory it's going to actually take.
And if the images are actually a high quality images they're going to take you taking too much memory
and yet and then your application is going to actually crash.
OK.
So make sure that you always artist's your applications on an actual device.
OK.
And here if you want to actually your images if you want your images to take actually less memory you
can actually assign for example a value for example first here for the layout for the required tweets
and 40 for the required height.
And this extra day on our project again.
So as you can see our application is running on this emulator and you can see does that we have these
images here.
OK.
And the quality of these images are a little bit low but you can see that our application is not actually
taking too much memory.
OK.
So hopefully that makes sense.
And now let's actually go back and say this customized this year that of a file.
And if you have any questions about these concepts that I am actually teaching you in this tutorial
please post the discussion in the course and then I'll do my best to answer all of your questions.
But for now let's actually adding some more lines of code here.
OK.
And here where we actually created these string objects as you can see here.
Let's actually create another string object here.
OK.
String and the name of this object is old RTX the animal name value.
OK.
Assignment operator and then I can just refer to the name of the animal name object that get text that
to string.
And here are let's actually add another vort here value on here.
What do you call the name of these other objects.
OK so we have an old x the animal name value we have an old text the animal power value and we have
an old text the animals speak about.
OK.
So now are actually adding some more lines of code here.
So now as you can see inside this emulator Now you can see that you need to assign the name of the animal
and animal power and animal to speed.
OK.
So here I can just type in the animal name that takes all the animal name value.
Plus as you can see we have an array here.
Animal names.
OK.
So we can just revert to the name of this Aure.
OK.
And inside of this sniffer as you can see animal names.
OK Suppe position.
So as you can see we have this position as an argument of this gets you might get a few Meffert.
OK.