Making simulation shaving using Image Lingo

zhaozj2021-02-16  69

Director 8 has a lot of incremental changes with respect to Director 7, where the LINGO programmer is the most striking thing to increase the relevant image lingo instruction. With it, we can do a lot of effects that have been unable to use Director 7, for example, you can write some transition transition effects, and you can also write filter effects similar to Photoshop. This further reflects the advantages of Director relative to Flash - ie: for powerful processing capabilities of bitmaps. Here we will tend to have a powerful feature that the new Image lingo command is given.

There are many people discussing Director and Flash in the forum, whether it is the domestic forum or abroad, the situation is the same. The supporters of both sides persuaded that the software I like as much as possible is the best, in fact, in many cases, this argument is no meaning. I use two softwares, I like to use Flash to make a simple animation role, then import Director, not all in Director in Director before Director. Make Film Loop animation. In terms of animation, Director is really not as Flash, but I still like to use Lingo to write a program. So I won't make all effects like a true Flasher ("Flash") to discover Flash's potential (although the effect is very boring, or the efficiency is too low, poor performance). Recently I have made a shaving knife demo project, further verifying the Director in handling the dot matrix image is indeed better than Flash.

In fact, this project is very simple: by dragging the razor in the web page, a person's face beard is scraped.

The first idea of ​​this project is to do with Flash. Our Flash technicians have the most beginning idea that the photo pattern (rectangular area) of this person's face beard is detained, then the same person's face does not have a beard photo (in order to achieve the head pattern is completely matched, We are treated with Photoshop to add beards on the same photo to many of the same small pieces, and then import flash as an element. This is divided into many small pieces into many small pieces, introduces Flash, and then divided into the same number of small pieces of small pieces, and then makes each of the corresponding one MC.

The first frame of this MC places a beard cutting pattern, and the second frame is placed without a barbbered cutting pattern. The first frame of the MC is placed. When the mouse OVER, let this MC beat to the second frame without beard Small cutting block. Thus, when the MC made of razor is replaced by the mouse, when it slides to these MC (with a bearded small cutting pattern), they will jump to the corresponding second frame (that is, there is no beard small cut block. Pattern), this can complete the fisherman's demo.

The method is very simple: but actually, there is a problem.

1: Usually such a sect file must be very thin to meet the customer's request, then cut the picture, more meticulous, it means to make more MC and Symbol in Flash. This not only increases the size of the file, but also makes the file run very slow.

2: Due to the cutting size of this method is set, if you want to cut the cut, you must go to the new sections and import. It is necessary to repeat labor.

3: This method makes SWF files typically much larger than DCR files made than Director (at least double).

With the Image Lingo directive of Director 8, you can avoid the above problems. The production method is as follows:

The material you need:

A photo bitmap without shaving, and a photo bitmap of the same man is scraping the beard. (For copyright issues, I removed the face part and retain the bitmap pattern of the beard part.) See the picture below:

Then we started to introduce the program part, this program is very short, the core part of the code is 6 lines. However, in order to understand these six lines of code, you need to know a core function of Director 8 added image lingo, this is CopyPixels

The functionality of CopyPixels is to copy bitmap data from an image to another.

Now any Director role (MEMBER) has an image of an image, which is a place that many people ignore. This image property is a reference to a graphics object in memory, and this graphic object is a graphical representation of a role member. The role member can be a bitmap, Flash role, text role, or even the stage stage. I started the two bitmap characters just imported as Source (scraping the beard photo bitmap face.jpg) and Targer (not shaved Beard photo bitmap faceoff.jpg)

The zoom map in the Director is as follows:

Control M Open the message window in Director, enter

PUT MEMBER ("Source"). Image

N - 1D151C is the address of the image object in memory.

The image property is a reference to actual data. The image graphic object is the actual data in the role member in memory.

Any changes to the image object are modifications to the corresponding original roles in Cast. This should be noted that unless Image object is created by yourself and does not associate with the role member, you must pay attention to the original role member of the original change.

You can call the image () function to create your own object. Examples are as follows:

Image (Width, Height, BitDepth)

Thanimage = Image (320, 240, 16)

You now created a width of 320 PIXEL high to 240 Pixel, the bit is a 16 bit graphic object.

You can add data to the graphic object with the CopyPixels function. The format of this function is as follows (this is the key to this program):

TargetImage.copypixels (SourceImage, DestinationRect, SourceRect,)

This function function is to call the CopyPixels function through the target graphics object, copy the source graphic object, rectangular area SourceRect from the source graphic object to the rectangular area DestinationRect of the target graphics object.

Taking this program as an example, our purpose: the program records the track of the mouse movement, starting from the upper left corner, record a virtual rectangular area, record this rectangular coordinate (relative to the top left corner of the graphic) . Then pass TargetImage (the role of our program "Target" - not shaved photo pattern) calls the CopyPixels function to save the SourceImage (the role of our program "Source" - post-shaved photo pattern) Mouse sliding rectangular area Graphics Copy to the corresponding TargetImage, remember that our changes to TargetImage roles directly change the Target role, so we must have another role, it is identical to the target role, but the name is different, for the time to restore Target The original appearance of the role. So we are copying the Target role from the new copy, placed on the top 3, and the name is "s". The following will explain why this is made. Now we create a MOVIE Script in this Director program to type the following statement

On Startmovie

MEMBER ("s"). duplicate (2) .member.name = "target"

- This statement is very simple, that is, copy the MEMBER role "S" to the role of the 2nd, then the name is "Target"

end

This way we restore the original look of the Target role.

The following is all characters, stations, and scorerts:

In this program, it is troublesome to do FLASH by using Director 8's clear image Lingo code. This is the advantage of Director in processing images. Flash is indeed obvious to the right amount, but I hope that everyone can pay more attention to Director for bitmap processing technology. It is the intention that I really want to express in different occasions.

转载请注明原文地址:https://www.9cbs.com/read-16004.html

New Post(0)