<< Chapter < Page Chapter >> Page >

The magenta and green color values

A magenta pixel is produced by setting the red and blue color bytes to full strength (255) and setting the green color byte to 0. A green pixel is produced by setting the red and blue color bytes to 0 and setting the green color byte to255.

You should be OK by now

Knowing what you now know, you should have no difficulty understanding how the data in the ByteArray object is modified to produce the magenta and green colored areas near the upper-left corner of the middle imageof Figure 1.

Not quite finished yet

Note, however that we haven't modified the actual pixel data in the bitmap yet. So far we have made a copy of all the pixel data in the rectangular region andhave modified the color values in the copy of the pixel data. We still need to write the modified pixel data back into the BitmapData object to actually modify the image.

Put the modified pixel data back into the same rectangular region

Listing 11 calls the setPixels method to store the pixel data that is contained in the rawBytes array back into the same rectangular region of the bitmap image.

Put the modified pixel data back into the same rectangular region.

rawBytes.position = 0;//this is critical bitmapData.setPixels(new Rectangle(10,10,50,8),rawBytes);

The position property of the ByteArray object

With one exception, you should have no difficulty understanding the code in Listing 11. That exception has to do with the ByteArray property named position . Here is what the documentation has to say about the position property:

"Moves, or returns the current position, in bytes, of the file pointer into the ByteArray object. This is the point at whichthe next call to a read method starts reading or a write method starts writing."

Whether or not you understand what that means, it is critical that you set the value of the position property to zero before calling the setPixels method to cause all of the data in the array to be written into the BitmapData object. Otherwise, you will get a runtime error.

Some things worth noting

A couple of things are worth noting. First, there was no technical requirement to write the data from the array back into the same rectangularregion from which it was read. It could have been written into a different rectangular region in the same bitmap, it could have been written into severaldifferent rectangular regions, or it could even have been written into a completely different BitmapData object.

No requirement to read the bitmap data

Second, since the code in Listing 10 stored color data into the array that was totally independent of the color values in the BitmapData object, there was no requirement to read the color data from the BitmapData object in the first place. We could simply have instantiated a new ByteArray object and set its length to the product of the width and the height of the rectangular region. Then we couldhave executed the code in Listing 10 to populate the bytes in the array with magenta and green color values. Then we could have executed the code in Listing11 to write the pixel data into an appropriate rectangular region in the BitmapData object.

Questions & Answers

what is defense mechanism
Chinaza Reply
what is defense mechanisms
Chinaza
I'm interested in biological psychology and cognitive psychology
Tanya Reply
what does preconceived mean
sammie Reply
physiological Psychology
Nwosu Reply
How can I develope my cognitive domain
Amanyire Reply
why is communication effective
Dakolo Reply
Communication is effective because it allows individuals to share ideas, thoughts, and information with others.
effective communication can lead to improved outcomes in various settings, including personal relationships, business environments, and educational settings. By communicating effectively, individuals can negotiate effectively, solve problems collaboratively, and work towards common goals.
it starts up serve and return practice/assessments.it helps find voice talking therapy also assessments through relaxed conversation.
miss
Every time someone flushes a toilet in the apartment building, the person begins to jumb back automatically after hearing the flush, before the water temperature changes. Identify the types of learning, if it is classical conditioning identify the NS, UCS, CS and CR. If it is operant conditioning, identify the type of consequence positive reinforcement, negative reinforcement or punishment
Wekolamo Reply
please i need answer
Wekolamo
because it helps many people around the world to understand how to interact with other people and understand them well, for example at work (job).
Manix Reply
Agreed 👍 There are many parts of our brains and behaviors, we really need to get to know. Blessings for everyone and happy Sunday!
ARC
A child is a member of community not society elucidate ?
JESSY Reply
Isn't practices worldwide, be it psychology, be it science. isn't much just a false belief of control over something the mind cannot truly comprehend?
Simon Reply
compare and contrast skinner's perspective on personality development on freud
namakula Reply
Skinner skipped the whole unconscious phenomenon and rather emphasized on classical conditioning
war
explain how nature and nurture affect the development and later the productivity of an individual.
Amesalu Reply
nature is an hereditary factor while nurture is an environmental factor which constitute an individual personality. so if an individual's parent has a deviant behavior and was also brought up in an deviant environment, observation of the behavior and the inborn trait we make the individual deviant.
Samuel
I am taking this course because I am hoping that I could somehow learn more about my chosen field of interest and due to the fact that being a PsyD really ignites my passion as an individual the more I hope to learn about developing and literally explore the complexity of my critical thinking skills
Zyryn Reply
good👍
Jonathan
and having a good philosophy of the world is like a sandwich and a peanut butter 👍
Jonathan
generally amnesi how long yrs memory loss
Kelu Reply
interpersonal relationships
Abdulfatai Reply
Got questions? Join the online conversation and get instant answers!
Jobilize.com Reply

Get Jobilize Job Search Mobile App in your pocket Now!

Get it on Google Play Download on the App Store Now




Source:  OpenStax, Object-oriented programming (oop) with actionscript. OpenStax CNX. Jun 04, 2010 Download for free at http://cnx.org/content/col11202/1.19
Google Play and the Google Play logo are trademarks of Google Inc.

Notification Switch

Would you like to follow the 'Object-oriented programming (oop) with actionscript' conversation and receive update notifications?

Ask