Demo or Die #02
31 июля 1999 |
|
Demo-Building - Radial blur, blur effect around the bitmap.
__________________________________________ Radial blur (C) Scorpion. Have you ever wondered how effect is a blur around the bitmap? In other words, filtering the bitmap with increase. On this and will be discussed in this article. Just want to note that This article is designed to more or less prepared by the encoder. In view of the brevity descriptions, will result in mostly algorithm. This effect consists of two main routines, a circular increasing (radial zoom) and filtering (blur). Radial zoom obtained as follows. First generated an array of hemispherical surface, followed by a given array construct a table of the actual address of the offset in the buffer bitmap (look up table). That is we need to have two arrays under bitmaps and two under the table of offsets. AND make a copy of the table of points one bitmap to another. It works well. In the loop sequentially through all the points of the first bitmap. For each point we choose appropriate item from the table displacements. She points to the point of the second bitmap, which must be taken. Kosvenno at this address take these points and copy the first bitmap. Now explain why it was necessary to tinker with Array duplicates. Case that If we copy the point of the bitmap to itself, then the new point will be overwrite all old and uncopied bitmap will be progressively distorted. More one moment. As is you may have noticed, the point not copied from the current array in an array duplicate, but instead of a duplicate current. The fact that the current array need to complete linearly, ie line by line. This approach is necessary so that after copying between points in the bitmap was no breaks. Now, regarding the generation of tables. For array can generate a hemisphere in each point X, Y array to calculate the value Features: Z = (X-Xts) * (X-Xts) + (Y-Yts) * (Y-Yts) where Xts, Yts - coordinates of the center of the array. In this case, by z we mean distance from the screen plane to hemisphere. It turns out a certain analogy tunnel. Now, with an array of hemisphere to calculate the delta bias points in the bitmap. Do it as follows. On the first pass calculate dX second dY. Delta offset will be equal to the difference between the two neighboring values of the hemisphere, then is: dX = Z (x +1, y)-Z (x, y) dY = Z (x, y +1)-Z (x, y) To find the coordinates of the displaced points need to coordinate points to add delta offset. Now we can calculate real address of the offset points: Adr = Base + Y * Xmax + X where Base - Location of the second array bitmap. X, Y - coordinates of the displaced point. Xmax - The length of the bitmap to X. These addresses are written in the first offset table. For the formation of the second offset table can be the first to address table to add a constant bias. Thus, to get a reference to the first bitmap. Once, when your bitmap increased in the amount it must poblyurit. This can be done ordinary averaging filter. Detail about it you could read DOD # 1. Let me remind you that it is necessary through all the points of our current bitmap, around each point put four neighboring, divide into four and the result is recorded in this point. After that, you need to change the buffer sites or markers of references to the buffer. Accordingly, the current will now the second array bitmap and the second table displacements. And repeat again. Now a few tips on the optimization. To work with the table displacement would be the best stack. Then is pushing POP'om of her address and it take the color point of the bitmap. I have it combined with the process of dithering. Output images take turns in two screen. HALT can be and not to, anyway beam is invisible, and faster speed and Turbe accelerated. About the blur. Division four faster to do on the table. Read from an array of bitmaps can not four, and the three adjacent points. The fourth is the battery from the previous times. Buffer better shape so that the least significant byte address is set to X, a senior Y. And then There is no need to compute address. Well, perhaps all, of what I wanted you tell. I hope you will understand the whole these delusions, and write a lot of major effects:). __________________________________________
Other articles:
Similar articles:
В этот день... 21 November