(C) 1997 Bob Klubov
Down with the horizontal!
This article will talk about two programs that are available
in the annex, which intended to rotate the image
respect to a given center at a certain angle. Tackle this
problem prompted me that the majority of all labels (names,
games, and megadem Other logos) are arranged horizontally or
vertically, which is already nabilo mouth. Konechnozhe a
spatial position due to the simplicity drawing, but you need to
improve the design of their programs. Can not be dismissed, and
the fact that the coloring Rotate image starts a war for life
and death with attributes. Well there can not help, twist
yourself as you want! Still need to stay on here any nuance:
when rotate the image angle is not a multiple
90 degrees there is insignificant
image distortion. The reason for these distortions can be
understood if we look
1 and read on.
For example, we turn
pixel 1 on the peak
Xela 0 to 45 degrees Po
clockwise in the pixel
2. Since the pixel element
tary element image
tion, is square, with two of its sides horizontally, and two
strictly vertical, then pixels 0 and 1 fall strictly within
their "Hot spot", but the pixel 2, all sides are inclined at 45
degrees and so there issue arises: which of the four "hole"
should be placed. In Ideally, the pixel 2 would need to
some way to leave such a
He is a (square, rotated 45 degrees).
So, in the annex to the magazine, there are two programs:
Rotat0.0 and Rotat1.0. First
of them work faster, but
not very good quality, the second slower
(Very slowly), but with higher quality. The results of both
programs are shown in Figure 2 (2a rotated by 45
degrees with Rotat0.0 - 2b, with
Rotat1.0 - Fig. 2c).
And now I try to tell about the program algorithm and why
they are, strictly speaking, two. Both programs work the same
externally:
1. asked: to show whether the directory?
2. Enter a name and upload pictures by
address 16384 and length 6144;
3. using the keys Q, A, O, P and M
indicates the center of rotation;
4. Enter the rotation angle (counterclockwise
arrows);
5. Enter a name for the shipment of "rotated
On "image;
6. rotate the image;
7. shipment of the pictures.
Algorithms also differ somewhat.
And the only difference itself rotate.
In Rotat0.0 rotation is as follows
as follows:
1. read into memory the coordinates of all
illuminated points (nx, ny);
2. clear screen;
3. each point is rotated by a
given angle around the center and press
is the new coordinate (rx, ry).
But the image with this algorithm is obtained by it to be.
The explanation for this, I I can not find, so I had to use a
different algorithm that works as it were, on the contrary. In
Rotat1.0 rotation is as follows:
1. take the coordinate of the lower-left point
(Nx, ny);
2. rotate the inverse of the
this, with new coordinates
(Rx, ry);
3. Consider, if marred by pixel to
ordinate (rx, ry). If marred, then
set point coordinate (nx, ny);
4. Go to the next point and the transition
paragraph 1, until all will go to
point of the screen, and their 256 * 176 pieces.
When using this algorithm, the image gets better. Longer
opening hours of the second algorithm due to the fact that it
loops through all pixels of the screen, not just overexposed,
as in Rotat0.0.
Yet it should be noted
that both programs on
97% written in the Basie
Ke and in consequence it
On strongly inhibit. I
not friends with Calculator
torus Spectrum, which is why
to write all of
BASIC.
Recently, rumors about
that many teams write graphical editors. So try to realize the
function of image rotation in their works, it is very
necessary.
Yes, I almost forgot: during the rotation
Image program Rotat0.0, new
built directly in the time of turning the program Rotat1.0, new
built in memory and only at the end is thrown on the screen.
Time of the first program depends on the
number of illuminated pixels, and the time
of the second - always about the same: a little over an hour
(who taught you so swear!).
At this time, our air has come to
end. Until next time
____________________________________