unpack zips in src to better compression
This commit is contained in:
503
sources/z-tools/trunk/zcodeclib/copyright
Normal file
503
sources/z-tools/trunk/zcodeclib/copyright
Normal file
@@ -0,0 +1,503 @@
|
||||
|
||||
GNU LESSER GENERAL PUBLIC LICENSE
|
||||
Version 2.1, February 1999
|
||||
|
||||
Copyright (C) 1991, 1999 Free Software Foundation, Inc.
|
||||
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
[This is the first released version of the Lesser GPL. It also counts
|
||||
as the successor of the GNU Library Public License, version 2, hence
|
||||
the version number 2.1.]
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
Licenses are intended to guarantee your freedom to share and change
|
||||
free software--to make sure the software is free for all its users.
|
||||
|
||||
This license, the Lesser General Public License, applies to some
|
||||
specially designated software packages--typically libraries--of the
|
||||
Free Software Foundation and other authors who decide to use it. You
|
||||
can use it too, but we suggest you first think carefully about whether
|
||||
this license or the ordinary General Public License is the better
|
||||
strategy to use in any particular case, based on the explanations below.
|
||||
|
||||
When we speak of free software, we are referring to freedom of use,
|
||||
not price. Our General Public Licenses are designed to make sure that
|
||||
you have the freedom to distribute copies of free software (and charge
|
||||
for this service if you wish); that you receive source code or can get
|
||||
it if you want it; that you can change the software and use pieces of
|
||||
it in new free programs; and that you are informed that you can do
|
||||
these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
distributors to deny you these rights or to ask you to surrender these
|
||||
rights. These restrictions translate to certain responsibilities for
|
||||
you if you distribute copies of the library or if you modify it.
|
||||
|
||||
For example, if you distribute copies of the library, whether gratis
|
||||
or for a fee, you must give the recipients all the rights that we gave
|
||||
you. You must make sure that they, too, receive or can get the source
|
||||
code. If you link other code with the library, you must provide
|
||||
complete object files to the recipients, so that they can relink them
|
||||
with the library after making changes to the library and recompiling
|
||||
it. And you must show them these terms so they know their rights.
|
||||
|
||||
We protect your rights with a two-step method: (1) we copyright the
|
||||
library, and (2) we offer you this license, which gives you legal
|
||||
permission to copy, distribute and/or modify the library.
|
||||
|
||||
To protect each distributor, we want to make it very clear that
|
||||
there is no warranty for the free library. Also, if the library is
|
||||
modified by someone else and passed on, the recipients should know
|
||||
that what they have is not the original version, so that the original
|
||||
author's reputation will not be affected by problems that might be
|
||||
introduced by others.
|
||||
|
||||
Finally, software patents pose a constant threat to the existence of
|
||||
any free program. We wish to make sure that a company cannot
|
||||
effectively restrict the users of a free program by obtaining a
|
||||
restrictive license from a patent holder. Therefore, we insist that
|
||||
any patent license obtained for a version of the library must be
|
||||
consistent with the full freedom of use specified in this license.
|
||||
|
||||
Most GNU software, including some libraries, is covered by the
|
||||
ordinary GNU General Public License. This license, the GNU Lesser
|
||||
General Public License, applies to certain designated libraries, and
|
||||
is quite different from the ordinary General Public License. We use
|
||||
this license for certain libraries in order to permit linking those
|
||||
libraries into non-free programs.
|
||||
|
||||
When a program is linked with a library, whether statically or using
|
||||
a shared library, the combination of the two is legally speaking a
|
||||
combined work, a derivative of the original library. The ordinary
|
||||
General Public License therefore permits such linking only if the
|
||||
entire combination fits its criteria of freedom. The Lesser General
|
||||
Public License permits more lax criteria for linking other code with
|
||||
the library.
|
||||
|
||||
We call this license the "Lesser" General Public License because it
|
||||
does Less to protect the user's freedom than the ordinary General
|
||||
Public License. It also provides other free software developers Less
|
||||
of an advantage over competing non-free programs. These disadvantages
|
||||
are the reason we use the ordinary General Public License for many
|
||||
libraries. However, the Lesser license provides advantages in certain
|
||||
special circumstances.
|
||||
|
||||
For example, on rare occasions, there may be a special need to
|
||||
encourage the widest possible use of a certain library, so that it becomes
|
||||
a de-facto standard. To achieve this, non-free programs must be
|
||||
allowed to use the library. A more frequent case is that a free
|
||||
library does the same job as widely used non-free libraries. In this
|
||||
case, there is little to gain by limiting the free library to free
|
||||
software only, so we use the Lesser General Public License.
|
||||
|
||||
In other cases, permission to use a particular library in non-free
|
||||
programs enables a greater number of people to use a large body of
|
||||
free software. For example, permission to use the GNU C Library in
|
||||
non-free programs enables many more people to use the whole GNU
|
||||
operating system, as well as its variant, the GNU/Linux operating
|
||||
system.
|
||||
|
||||
Although the Lesser General Public License is Less protective of the
|
||||
users' freedom, it does ensure that the user of a program that is
|
||||
linked with the Library has the freedom and the wherewithal to run
|
||||
that program using a modified version of the Library.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow. Pay close attention to the difference between a
|
||||
"work based on the library" and a "work that uses the library". The
|
||||
former contains code derived from the library, whereas the latter must
|
||||
be combined with the library in order to run.
|
||||
|
||||
GNU LESSER GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License Agreement applies to any software library or other
|
||||
program which contains a notice placed by the copyright holder or
|
||||
other authorized party saying it may be distributed under the terms of
|
||||
this Lesser General Public License (also called "this License").
|
||||
Each licensee is addressed as "you".
|
||||
|
||||
A "library" means a collection of software functions and/or data
|
||||
prepared so as to be conveniently linked with application programs
|
||||
(which use some of those functions and data) to form executables.
|
||||
|
||||
The "Library", below, refers to any such software library or work
|
||||
which has been distributed under these terms. A "work based on the
|
||||
Library" means either the Library or any derivative work under
|
||||
copyright law: that is to say, a work containing the Library or a
|
||||
portion of it, either verbatim or with modifications and/or translated
|
||||
straightforwardly into another language. (Hereinafter, translation is
|
||||
included without limitation in the term "modification".)
|
||||
|
||||
"Source code" for a work means the preferred form of the work for
|
||||
making modifications to it. For a library, complete source code means
|
||||
all the source code for all modules it contains, plus any associated
|
||||
interface definition files, plus the scripts used to control compilation
|
||||
and installation of the library.
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running a program using the Library is not restricted, and output from
|
||||
such a program is covered only if its contents constitute a work based
|
||||
on the Library (independent of the use of the Library in a tool for
|
||||
writing it). Whether that is true depends on what the Library does
|
||||
and what the program that uses the Library does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Library's
|
||||
complete source code as you receive it, in any medium, provided that
|
||||
you conspicuously and appropriately publish on each copy an
|
||||
appropriate copyright notice and disclaimer of warranty; keep intact
|
||||
all the notices that refer to this License and to the absence of any
|
||||
warranty; and distribute a copy of this License along with the
|
||||
Library.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy,
|
||||
and you may at your option offer warranty protection in exchange for a
|
||||
fee.
|
||||
|
||||
2. You may modify your copy or copies of the Library or any portion
|
||||
of it, thus forming a work based on the Library, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
a) The modified work must itself be a software library.
|
||||
|
||||
b) You must cause the files modified to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
c) You must cause the whole of the work to be licensed at no
|
||||
charge to all third parties under the terms of this License.
|
||||
|
||||
d) If a facility in the modified Library refers to a function or a
|
||||
table of data to be supplied by an application program that uses
|
||||
the facility, other than as an argument passed when the facility
|
||||
is invoked, then you must make a good faith effort to ensure that,
|
||||
in the event an application does not supply such function or
|
||||
table, the facility still operates, and performs whatever part of
|
||||
its purpose remains meaningful.
|
||||
|
||||
(For example, a function in a library to compute square roots has
|
||||
a purpose that is entirely well-defined independent of the
|
||||
application. Therefore, Subsection 2d requires that any
|
||||
application-supplied function or table used by this function must
|
||||
be optional: if the application does not supply it, the square
|
||||
root function must still compute square roots.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Library,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Library, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote
|
||||
it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Library.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Library
|
||||
with the Library (or with a work based on the Library) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may opt to apply the terms of the ordinary GNU General Public
|
||||
License instead of this License to a given copy of the Library. To do
|
||||
this, you must alter all the notices that refer to this License, so
|
||||
that they refer to the ordinary GNU General Public License, version 2,
|
||||
instead of to this License. (If a newer version than version 2 of the
|
||||
ordinary GNU General Public License has appeared, then you can specify
|
||||
that version instead if you wish.) Do not make any other change in
|
||||
these notices.
|
||||
|
||||
Once this change is made in a given copy, it is irreversible for
|
||||
that copy, so the ordinary GNU General Public License applies to all
|
||||
subsequent copies and derivative works made from that copy.
|
||||
|
||||
This option is useful when you wish to copy part of the code of
|
||||
the Library into a program that is not a library.
|
||||
|
||||
4. You may copy and distribute the Library (or a portion or
|
||||
derivative of it, under Section 2) in object code or executable form
|
||||
under the terms of Sections 1 and 2 above provided that you accompany
|
||||
it with the complete corresponding machine-readable source code, which
|
||||
must be distributed under the terms of Sections 1 and 2 above on a
|
||||
medium customarily used for software interchange.
|
||||
|
||||
If distribution of object code is made by offering access to copy
|
||||
from a designated place, then offering equivalent access to copy the
|
||||
source code from the same place satisfies the requirement to
|
||||
distribute the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
5. A program that contains no derivative of any portion of the
|
||||
Library, but is designed to work with the Library by being compiled or
|
||||
linked with it, is called a "work that uses the Library". Such a
|
||||
work, in isolation, is not a derivative work of the Library, and
|
||||
therefore falls outside the scope of this License.
|
||||
|
||||
However, linking a "work that uses the Library" with the Library
|
||||
creates an executable that is a derivative of the Library (because it
|
||||
contains portions of the Library), rather than a "work that uses the
|
||||
library". The executable is therefore covered by this License.
|
||||
Section 6 states terms for distribution of such executables.
|
||||
|
||||
When a "work that uses the Library" uses material from a header file
|
||||
that is part of the Library, the object code for the work may be a
|
||||
derivative work of the Library even though the source code is not.
|
||||
Whether this is true is especially significant if the work can be
|
||||
linked without the Library, or if the work is itself a library. The
|
||||
threshold for this to be true is not precisely defined by law.
|
||||
|
||||
If such an object file uses only numerical parameters, data
|
||||
structure layouts and accessors, and small macros and small inline
|
||||
functions (ten lines or less in length), then the use of the object
|
||||
file is unrestricted, regardless of whether it is legally a derivative
|
||||
work. (Executables containing this object code plus portions of the
|
||||
Library will still fall under Section 6.)
|
||||
|
||||
Otherwise, if the work is a derivative of the Library, you may
|
||||
distribute the object code for the work under the terms of Section 6.
|
||||
Any executables containing that work also fall under Section 6,
|
||||
whether or not they are linked directly with the Library itself.
|
||||
|
||||
6. As an exception to the Sections above, you may also combine or
|
||||
link a "work that uses the Library" with the Library to produce a
|
||||
work containing portions of the Library, and distribute that work
|
||||
under terms of your choice, provided that the terms permit
|
||||
modification of the work for the customer's own use and reverse
|
||||
engineering for debugging such modifications.
|
||||
|
||||
You must give prominent notice with each copy of the work that the
|
||||
Library is used in it and that the Library and its use are covered by
|
||||
this License. You must supply a copy of this License. If the work
|
||||
during execution displays copyright notices, you must include the
|
||||
copyright notice for the Library among them, as well as a reference
|
||||
directing the user to the copy of this License. Also, you must do one
|
||||
of these things:
|
||||
|
||||
a) Accompany the work with the complete corresponding
|
||||
machine-readable source code for the Library including whatever
|
||||
changes were used in the work (which must be distributed under
|
||||
Sections 1 and 2 above); and, if the work is an executable linked
|
||||
with the Library, with the complete machine-readable "work that
|
||||
uses the Library", as object code and/or source code, so that the
|
||||
user can modify the Library and then relink to produce a modified
|
||||
executable containing the modified Library. (It is understood
|
||||
that the user who changes the contents of definitions files in the
|
||||
Library will not necessarily be able to recompile the application
|
||||
to use the modified definitions.)
|
||||
|
||||
b) Use a suitable shared library mechanism for linking with the
|
||||
Library. A suitable mechanism is one that (1) uses at run time a
|
||||
copy of the library already present on the user's computer system,
|
||||
rather than copying library functions into the executable, and (2)
|
||||
will operate properly with a modified version of the library, if
|
||||
the user installs one, as long as the modified version is
|
||||
interface-compatible with the version that the work was made with.
|
||||
|
||||
c) Accompany the work with a written offer, valid for at
|
||||
least three years, to give the same user the materials
|
||||
specified in Subsection 6a, above, for a charge no more
|
||||
than the cost of performing this distribution.
|
||||
|
||||
d) If distribution of the work is made by offering access to copy
|
||||
from a designated place, offer equivalent access to copy the above
|
||||
specified materials from the same place.
|
||||
|
||||
e) Verify that the user has already received a copy of these
|
||||
materials or that you have already sent this user a copy.
|
||||
|
||||
For an executable, the required form of the "work that uses the
|
||||
Library" must include any data and utility programs needed for
|
||||
reproducing the executable from it. However, as a special exception,
|
||||
the materials to be distributed need not include anything that is
|
||||
normally distributed (in either source or binary form) with the major
|
||||
components (compiler, kernel, and so on) of the operating system on
|
||||
which the executable runs, unless that component itself accompanies
|
||||
the executable.
|
||||
|
||||
It may happen that this requirement contradicts the license
|
||||
restrictions of other proprietary libraries that do not normally
|
||||
accompany the operating system. Such a contradiction means you cannot
|
||||
use both them and the Library together in an executable that you
|
||||
distribute.
|
||||
|
||||
7. You may place library facilities that are a work based on the
|
||||
Library side-by-side in a single library together with other library
|
||||
facilities not covered by this License, and distribute such a combined
|
||||
library, provided that the separate distribution of the work based on
|
||||
the Library and of the other library facilities is otherwise
|
||||
permitted, and provided that you do these two things:
|
||||
|
||||
a) Accompany the combined library with a copy of the same work
|
||||
based on the Library, uncombined with any other library
|
||||
facilities. This must be distributed under the terms of the
|
||||
Sections above.
|
||||
|
||||
b) Give prominent notice with the combined library of the fact
|
||||
that part of it is a work based on the Library, and explaining
|
||||
where to find the accompanying uncombined form of the same work.
|
||||
|
||||
8. You may not copy, modify, sublicense, link with, or distribute
|
||||
the Library except as expressly provided under this License. Any
|
||||
attempt otherwise to copy, modify, sublicense, link with, or
|
||||
distribute the Library is void, and will automatically terminate your
|
||||
rights under this License. However, parties who have received copies,
|
||||
or rights, from you under this License will not have their licenses
|
||||
terminated so long as such parties remain in full compliance.
|
||||
|
||||
9. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Library or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Library (or any work based on the
|
||||
Library), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Library or works based on it.
|
||||
|
||||
10. Each time you redistribute the Library (or any work based on the
|
||||
Library), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute, link with or modify the Library
|
||||
subject to these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties with
|
||||
this License.
|
||||
|
||||
11. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Library at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Library by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Library.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under any
|
||||
particular circumstance, the balance of the section is intended to apply,
|
||||
and the section as a whole is intended to apply in other circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
12. If the distribution and/or use of the Library is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Library under this License may add
|
||||
an explicit geographical distribution limitation excluding those countries,
|
||||
so that distribution is permitted only in or among countries not thus
|
||||
excluded. In such case, this License incorporates the limitation as if
|
||||
written in the body of this License.
|
||||
|
||||
13. The Free Software Foundation may publish revised and/or new
|
||||
versions of the Lesser General Public License from time to time.
|
||||
Such new versions will be similar in spirit to the present version,
|
||||
but may differ in detail to address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Library
|
||||
specifies a version number of this License which applies to it and
|
||||
"any later version", you have the option of following the terms and
|
||||
conditions either of that version or of any later version published by
|
||||
the Free Software Foundation. If the Library does not specify a
|
||||
license version number, you may choose any version ever published by
|
||||
the Free Software Foundation.
|
||||
|
||||
14. If you wish to incorporate parts of the Library into other free
|
||||
programs whose distribution conditions are incompatible with these,
|
||||
write to the author to ask for permission. For software which is
|
||||
copyrighted by the Free Software Foundation, write to the Free
|
||||
Software Foundation; we sometimes make exceptions for this. Our
|
||||
decision will be guided by the two goals of preserving the free status
|
||||
of all derivatives of our free software and of promoting the sharing
|
||||
and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
|
||||
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
|
||||
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
|
||||
OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
|
||||
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
|
||||
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
|
||||
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
|
||||
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
|
||||
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
|
||||
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
|
||||
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
|
||||
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
|
||||
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
|
||||
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
|
||||
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
|
||||
DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Libraries
|
||||
|
||||
If you develop a new library, and you want it to be of the greatest
|
||||
possible use to the public, we recommend making it free software that
|
||||
everyone can redistribute and change. You can do so by permitting
|
||||
redistribution under these terms (or, alternatively, under the terms of the
|
||||
ordinary General Public License).
|
||||
|
||||
To apply these terms, attach the following notices to the library. It is
|
||||
safest to attach them to the start of each source file to most effectively
|
||||
convey the exclusion of warranty; and each file should have at least the
|
||||
"copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the library's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the library, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the
|
||||
library `Frob' (a library for tweaking knobs) written by James Random Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1990
|
||||
Ty Coon, President of Vice
|
||||
|
||||
That's all there is to it!
|
||||
BIN
sources/z-tools/trunk/zcodeclib/exemple/8.gif
Normal file
BIN
sources/z-tools/trunk/zcodeclib/exemple/8.gif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 85 KiB |
BIN
sources/z-tools/trunk/zcodeclib/exemple/exemple.app
Normal file
BIN
sources/z-tools/trunk/zcodeclib/exemple/exemple.app
Normal file
Binary file not shown.
89
sources/z-tools/trunk/zcodeclib/exemple/main.c
Normal file
89
sources/z-tools/trunk/zcodeclib/exemple/main.c
Normal file
@@ -0,0 +1,89 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <osbind.h>
|
||||
#include <mintbind.h>
|
||||
#include <gem.h>
|
||||
#include <ldg.h>
|
||||
#include <types2b.h>
|
||||
#include <zcodec.h>
|
||||
|
||||
|
||||
int main( int argc, char *argv[])
|
||||
{
|
||||
IMAGE *test_img = NULL;
|
||||
MFDB *resize = NULL, screen = {0};
|
||||
int16 xy[8];
|
||||
|
||||
/* We load the wanted codecs but if we want to
|
||||
load the entire codecs's pack, we can do "codecs_init( "all"); */
|
||||
if( !codecs_init( "gif.ldg"))
|
||||
Cconws("can't init the codec \n\r");
|
||||
|
||||
if ( argc > 1)
|
||||
{ /* we load the dragged picture, we put - 1 to both w and h options because we don't want zoom */
|
||||
if( ! (test_img = load_img( argv[argc - 1], -1, -1, 0)))
|
||||
{
|
||||
Cconws("can't load image \n\r");
|
||||
codecs_quit();
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Cconws("Drag and Drop a gif image\n\r");
|
||||
codecs_quit();
|
||||
return 0;
|
||||
}
|
||||
|
||||
xy[0] = 0;
|
||||
xy[1] = 0;
|
||||
xy[2] = test_img->image[0].fd_w - 1;
|
||||
xy[3] = test_img->image[0].fd_h - 1;
|
||||
xy[4] = 20;
|
||||
xy[5] = 20;
|
||||
xy[6] = xy[4] + xy[2];
|
||||
xy[7] = xy[5] + xy[3];
|
||||
|
||||
if ( test_img->image[0].fd_nplanes == 1)
|
||||
{
|
||||
int16 color[2] = { 0, 1};
|
||||
|
||||
vrt_cpyfm( vdi_handle, MD_REPLACE, xy, &test_img->image[0], &screen, color);
|
||||
}
|
||||
else
|
||||
vro_cpyfm( vdi_handle, S_ONLY, xy, &test_img->image[0], &screen);
|
||||
|
||||
if( !( resize = pic_resize( &test_img->image[0],64, 64, 1)))
|
||||
{
|
||||
Cconws("can't resize image \n\r");
|
||||
delete_img( test_img);
|
||||
codecs_quit();
|
||||
return 0;
|
||||
}
|
||||
|
||||
xy[0] = 0;
|
||||
xy[1] = 0;
|
||||
xy[2] = resize->fd_w - 1;
|
||||
xy[3] = resize->fd_h - 1;
|
||||
xy[4] = 20 + test_img->image[0].fd_w - 1;
|
||||
xy[5] = 20;
|
||||
xy[6] = xy[4] + xy[2];
|
||||
xy[7] = xy[5] + xy[3];
|
||||
|
||||
/* draw the image */
|
||||
if ( resize->fd_nplanes == 1)
|
||||
{
|
||||
int16 color[2] = { 0, 1};
|
||||
|
||||
vrt_cpyfm( vdi_handle, MD_REPLACE, xy, resize, &screen, color);
|
||||
}
|
||||
else
|
||||
vro_cpyfm( vdi_handle, S_ONLY, xy, resize, &screen);
|
||||
|
||||
|
||||
delete_mfdb( resize, 1);
|
||||
delete_img( test_img);
|
||||
codecs_quit();
|
||||
return 0;
|
||||
}
|
||||
41
sources/z-tools/trunk/zcodeclib/exemple/makefile
Normal file
41
sources/z-tools/trunk/zcodeclib/exemple/makefile
Normal file
@@ -0,0 +1,41 @@
|
||||
ifeq ($(CROSS),yes)
|
||||
AS = m68k-atari-mint-as
|
||||
CC = m68k-atari-mint-gcc
|
||||
STACK = m68k-atari-mint-stack
|
||||
INCLUDE_PATH = /home/zorro/cross-tools/include
|
||||
LIB_PATH = /home/zorro/cross-tools/lib
|
||||
else
|
||||
AS = as
|
||||
CC = gcc
|
||||
STACK = stack
|
||||
INCLUDE_PATH = /usr/GEM/include
|
||||
LIB_PATH = /usr/GEM/lib
|
||||
endif
|
||||
|
||||
STACKSIZE = 128k
|
||||
COMPRESS = upx
|
||||
OPTIMISATION = -O2 -fomit-frame-pointer -finline-functions
|
||||
CPU = -m68020-60
|
||||
LIB = -lzcodec -lgem -lldg
|
||||
|
||||
CFLAGS = $(CPU) $(OPTIMISATION) -Wall -I$(INCLUDE_PATH)
|
||||
|
||||
OBJ = main.o
|
||||
|
||||
PROGRAM = exemple.app
|
||||
|
||||
|
||||
all: $(PROGRAM) stack #compress
|
||||
|
||||
$(PROGRAM): $(OBJ)
|
||||
$(CC) -o$@ $(OBJ) -Xlinker -s -L$(LIB_PATH) $(LIB)
|
||||
|
||||
stack:
|
||||
$(STACK) -S $(STACKSIZE) $(PROGRAM)
|
||||
|
||||
compress:
|
||||
$(COMPRESS) $(PROGRAM)
|
||||
|
||||
clean:
|
||||
rm -f *.o
|
||||
|
||||
43
sources/z-tools/trunk/zcodeclib/include/types2b.h
Normal file
43
sources/z-tools/trunk/zcodeclib/include/types2b.h
Normal file
@@ -0,0 +1,43 @@
|
||||
#ifndef __2B_UNIVERSAL_TYPES__
|
||||
#define __2B_UNIVERSAL_TYPES__
|
||||
|
||||
typedef signed char int8;
|
||||
typedef unsigned char uint8;
|
||||
typedef signed long int32;
|
||||
typedef unsigned long uint32;
|
||||
typedef int32 fix31;
|
||||
|
||||
#ifdef __GNUC__
|
||||
typedef signed short int16;
|
||||
typedef unsigned short uint16;
|
||||
#define __2B_HAS64_SUPPORT /* Compiler supports 64 Bit Integers */
|
||||
typedef signed long long int64;
|
||||
typedef unsigned long long uint64;
|
||||
#else /* Compiler doesn't support 64 Bit Integers */
|
||||
typedef signed int int16;
|
||||
typedef unsigned int uint16;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int32 hi;
|
||||
uint32 lo;
|
||||
} int64;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int32 hi;
|
||||
uint32 lo;
|
||||
} loff_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint32 hi;
|
||||
uint32 lo;
|
||||
} uint64;
|
||||
#endif
|
||||
|
||||
|
||||
typedef int32 boolean;
|
||||
|
||||
|
||||
#endif /* __2B_UNIVERSAL_TYPES__ */
|
||||
29
sources/z-tools/trunk/zcodeclib/include/zcodec.h
Normal file
29
sources/z-tools/trunk/zcodeclib/include/zcodec.h
Normal file
@@ -0,0 +1,29 @@
|
||||
#ifndef __ZCODECLIB_ZCODEC_H__
|
||||
#define __ZCODECLIB_ZCODEC_H__
|
||||
|
||||
#include <types2b.h>
|
||||
|
||||
struct LDG;
|
||||
struct MFDB;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int16 page; /* Number of page/image in the file */
|
||||
uint16 *delay; /* Animation delay in millise. between each frame */
|
||||
MFDB *image; /* The Image itself */
|
||||
}IMAGE;
|
||||
|
||||
extern int16 planar, vdi_handle, nplanes, vdi_work_in[10], vdi_work_out[57];
|
||||
extern LDG *ldg_mem;
|
||||
|
||||
extern int16 codecs_init( char *codec_name);
|
||||
extern void codecs_quit( void);
|
||||
extern IMAGE *load_img( const char *file, int16 w, int16 h, int16 keep_ratio);
|
||||
extern void delete_img( IMAGE *img);
|
||||
extern MFDB *pic_resize( MFDB *in, int16 w, int16 h, int16 keep_ratio);
|
||||
extern void delete_mfdb( MFDB *bm, int16 nbr);
|
||||
|
||||
#define shared_malloc( s) _ldg_malloc( s, ldg_global[2]);
|
||||
#define shared_free( s) _ldg_free( s, ldg_global[2]);
|
||||
|
||||
#endif
|
||||
29
sources/z-tools/trunk/zcodeclib/src/Makefile
Normal file
29
sources/z-tools/trunk/zcodeclib/src/Makefile
Normal file
@@ -0,0 +1,29 @@
|
||||
ifeq ($(CROSS),yes)
|
||||
AS = m68k-atari-mint-as
|
||||
AR = m68k-atari-mint-ar
|
||||
CC = m68k-atari-mint-gcc
|
||||
STACK = m68k-atari-mint-stack
|
||||
else
|
||||
AS = as
|
||||
AR = ar
|
||||
CC = gcc
|
||||
STACK = stack
|
||||
endif
|
||||
|
||||
OPTIMISATION = -O2 -fomit-frame-pointer
|
||||
CPU = -m68020-60
|
||||
|
||||
CFLAGS = $(CPU) $(OPTIMISATION) -Wall -I../include
|
||||
|
||||
VDI_OBJ = zvdi/p2c.o zvdi/color.o zvdi/dither.o zvdi/raster.o zvdi/raresize.o zvdi/vdi.o
|
||||
|
||||
OBJ = $(VDI_OBJ) img.o resize.o codecs.o mfdb.o load_img.o ztext.o mem.o
|
||||
|
||||
TARGET = ../lib/m68020-60/libzcodec.a
|
||||
|
||||
$(TARGET): $(OBJ)
|
||||
rm -f $@
|
||||
$(AR) cru $@ $^
|
||||
|
||||
clean:
|
||||
rm -f *.o zvdi/*.o *.O zvdi/*.O *~ $(TARGET)
|
||||
142
sources/z-tools/trunk/zcodeclib/src/codecs.c
Normal file
142
sources/z-tools/trunk/zcodeclib/src/codecs.c
Normal file
@@ -0,0 +1,142 @@
|
||||
#include "general.h"
|
||||
#include "ztext.h"
|
||||
#include "zvdi/vdi.h"
|
||||
|
||||
|
||||
/* Prototype */
|
||||
int16 plugins_init( void);
|
||||
void plugins_quit( void);
|
||||
|
||||
/* LDG function */
|
||||
void CDECL( *codec_init)( void) = NULL;
|
||||
|
||||
static int16 vdi_initialised = 0;
|
||||
static int16 mem_initialised = 0;
|
||||
|
||||
/* Global variable */
|
||||
int16 plugins_nbr = 0;
|
||||
LDG *codecs[100];
|
||||
|
||||
|
||||
/*==================================================================================*
|
||||
* void plugins_quit: *
|
||||
* unload all the codec from memory. *
|
||||
*----------------------------------------------------------------------------------*
|
||||
* input: *
|
||||
* -- *
|
||||
*----------------------------------------------------------------------------------*
|
||||
* returns: *
|
||||
* -- *
|
||||
*==================================================================================*/
|
||||
void codecs_quit( void)
|
||||
{
|
||||
int16 i;
|
||||
|
||||
for( i = 0; i < plugins_nbr; i++)
|
||||
{
|
||||
ldg_close( codecs[i], ldg_global);
|
||||
}
|
||||
|
||||
mem_quit();
|
||||
}
|
||||
|
||||
|
||||
/*==================================================================================*
|
||||
* void plugins_init: *
|
||||
* load codec(s) to memory. *
|
||||
*----------------------------------------------------------------------------------*
|
||||
* input: *
|
||||
* codec_name: the name of the codec to load, if this one is "all", we load *
|
||||
* the codec. *
|
||||
*----------------------------------------------------------------------------------*
|
||||
* returns: *
|
||||
* 0 if error. *
|
||||
*==================================================================================*/
|
||||
int16 codecs_init( char *codec_name)
|
||||
{
|
||||
char *env_ldg, current_dir[1024], plugin_dir[1024];
|
||||
DIR *dir;
|
||||
LDG_INFOS *cook;
|
||||
struct dirent *de;
|
||||
int16 len;
|
||||
char extention[4];
|
||||
|
||||
shel_envrn( &env_ldg, "LDGPATH=");
|
||||
|
||||
if( ldg_cookie( LDG_COOKIE, ( int32*)&cook))
|
||||
strcpy( plugin_dir, cook->path);
|
||||
else if( env_ldg)
|
||||
strcpy( plugin_dir, env_ldg);
|
||||
else
|
||||
strcpy( plugin_dir, "C:\\gemsys\\ldg\\");
|
||||
|
||||
len = ( int16)strlen( plugin_dir);
|
||||
|
||||
if( plugin_dir[len-1] != '\\')
|
||||
strcat( plugin_dir, "\\");
|
||||
|
||||
strcat( plugin_dir, "codecs");
|
||||
|
||||
current_dir[0] = 'A' + Dgetdrv();
|
||||
current_dir[1] = ':';
|
||||
Dgetpath( current_dir + 2, 0);
|
||||
|
||||
if( vdi_initialised == 0)
|
||||
if( !( vdi_initialised = vdi_init()))
|
||||
return( 0);
|
||||
|
||||
if( mem_initialised == 0)
|
||||
if( !( mem_initialised = mem_init()))
|
||||
return( 0);
|
||||
|
||||
if ( chdir( plugin_dir) != 0)
|
||||
{
|
||||
mem_quit();
|
||||
return( 0);
|
||||
}
|
||||
|
||||
if( strcmp ( codec_name, "all") == 0)
|
||||
{
|
||||
if (( dir = opendir( ".")) != NULL)
|
||||
{
|
||||
while(( de = readdir( dir)) != NULL)
|
||||
{
|
||||
if (( strcmp( de->d_name, ".") == 0) || ( strcmp( de->d_name, "..") == 0))
|
||||
continue;
|
||||
|
||||
strcpy ( extention, de->d_name + strlen( de->d_name) - 3);
|
||||
str2lower( extention);
|
||||
|
||||
if( strcmp ( extention, "ldg") == 0)
|
||||
{
|
||||
if ( ( codecs[plugins_nbr] = ldg_open( de->d_name, ldg_global)))
|
||||
{
|
||||
if ( ( codec_init = ldg_find( "plugin_init", codecs[plugins_nbr])))
|
||||
{
|
||||
codec_init();
|
||||
plugins_nbr++;
|
||||
}
|
||||
else
|
||||
ldg_close( codecs[plugins_nbr], ldg_global);
|
||||
}
|
||||
}
|
||||
}
|
||||
closedir( dir);
|
||||
}
|
||||
}
|
||||
else if ( ( codecs[plugins_nbr] = ldg_open( codec_name, ldg_global)))
|
||||
{
|
||||
if ( ( codec_init = ldg_find( "plugin_init", codecs[plugins_nbr])))
|
||||
{
|
||||
codec_init();
|
||||
plugins_nbr++;
|
||||
}
|
||||
else
|
||||
ldg_close( codecs[plugins_nbr], ldg_global);
|
||||
}
|
||||
|
||||
chdir( current_dir);
|
||||
|
||||
return plugins_nbr;
|
||||
}
|
||||
|
||||
2
sources/z-tools/trunk/zcodeclib/src/codecs.h
Normal file
2
sources/z-tools/trunk/zcodeclib/src/codecs.h
Normal file
@@ -0,0 +1,2 @@
|
||||
extern LDG *codecs[100];
|
||||
extern int16 plugins_nbr;
|
||||
44
sources/z-tools/trunk/zcodeclib/src/general.h
Normal file
44
sources/z-tools/trunk/zcodeclib/src/general.h
Normal file
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* zcodeclib.
|
||||
* Copyright (c) 2001-2005 Zorro ( zorro270@yahoo.fr)
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <osbind.h>
|
||||
#include <mintbind.h>
|
||||
#include <dirent.h>
|
||||
#include <unistd.h>
|
||||
#include <gemx.h>
|
||||
#include <ldg.h>
|
||||
#include <ldg/mem.h>
|
||||
#include <types2b.h>
|
||||
#include "mem.h"
|
||||
|
||||
#define shared_malloc( s) _ldg_malloc( s, ldg_global[2]);
|
||||
#define shared_free( s) _ldg_free( s, ldg_global[2]);
|
||||
|
||||
#ifndef MIN
|
||||
#define MAX(a,b) ((a)>(b)?(a):(b))
|
||||
#define MIN(a,b) ((a)<(b)?(a):(b))
|
||||
#endif
|
||||
|
||||
#ifndef TRUE
|
||||
# define TRUE 1
|
||||
# define FALSE 0
|
||||
#endif
|
||||
|
||||
53
sources/z-tools/trunk/zcodeclib/src/img.c
Normal file
53
sources/z-tools/trunk/zcodeclib/src/img.c
Normal file
@@ -0,0 +1,53 @@
|
||||
#include "general.h"
|
||||
#include "mfdb.h"
|
||||
#include "load_img.h"
|
||||
|
||||
IMAGE *init_img( int16 page, int16 w, int16 h, int16 planes)
|
||||
{
|
||||
IMAGE *data;
|
||||
int16 i;
|
||||
|
||||
data = ( IMAGE *)shared_malloc( sizeof( IMAGE));
|
||||
|
||||
if( data == NULL)
|
||||
return NULL;
|
||||
|
||||
data->page = page;
|
||||
data->delay = NULL;
|
||||
|
||||
data->image = ( MFDB *)shared_malloc( sizeof( MFDB) * page);
|
||||
|
||||
if( data->image == NULL)
|
||||
{
|
||||
shared_free( data);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
for ( i = 0 ; i < page ; i++)
|
||||
{
|
||||
if ( !init_mfdb( &data->image[i], w, h, planes))
|
||||
{
|
||||
if( i)
|
||||
delete_mfdb( data->image, i + 1);
|
||||
|
||||
shared_free( data->image);
|
||||
shared_free( data);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
void delete_img( IMAGE *data)
|
||||
{
|
||||
if( data == NULL)
|
||||
return;
|
||||
|
||||
delete_mfdb( data->image, data->page);
|
||||
|
||||
if( data->delay)
|
||||
shared_free( data->delay);
|
||||
|
||||
shared_free( data);
|
||||
}
|
||||
3
sources/z-tools/trunk/zcodeclib/src/img.h
Normal file
3
sources/z-tools/trunk/zcodeclib/src/img.h
Normal file
@@ -0,0 +1,3 @@
|
||||
extern IMAGE *init_img( int16 page, int16 w, int16 h, int16 planes);
|
||||
extern void delete_img( IMAGE *data);
|
||||
|
||||
259
sources/z-tools/trunk/zcodeclib/src/load_img.c
Normal file
259
sources/z-tools/trunk/zcodeclib/src/load_img.c
Normal file
@@ -0,0 +1,259 @@
|
||||
#include "general.h"
|
||||
#include "codecs.h"
|
||||
#include "load_img.h"
|
||||
#include "img.h"
|
||||
#include "ztext.h"
|
||||
#include "zvdi/color.h"
|
||||
#include "zvdi/raster.h"
|
||||
#include "zvdi/vdi.h"
|
||||
|
||||
boolean decoder_init_done = FALSE;
|
||||
|
||||
void ( *raster) ( DECDATA, void *dst);
|
||||
void ( *raster_cmap) ( DECDATA, void *);
|
||||
void ( *raster_true) ( DECDATA, void *);
|
||||
void ( *cnvpal_color) ( IMGINFO, DECDATA);
|
||||
void ( *raster_gray) ( DECDATA, void *);
|
||||
void CDECL ( *decoder_quit) ( IMGINFO);
|
||||
boolean CDECL ( *decoder_init) ( const char *, IMGINFO);
|
||||
boolean CDECL ( *decoder_read) ( IMGINFO, uint8 *);
|
||||
|
||||
|
||||
static IMAGE *setup ( IMGINFO info, DECDATA data, int16 w, int16 h, int16 keep_ratio)
|
||||
{
|
||||
int16 n_planes = ( ( info->planes == 1 && info->components == 1) ? 1: nplanes);
|
||||
uint16 display_w, display_h;
|
||||
int16 wanted_w = ( w > 0 ? w : info->width), wanted_h = ( h > 0 ? h : info->height);
|
||||
float precise_x, precise_y;
|
||||
size_t src_line_size;
|
||||
IMAGE *image;
|
||||
|
||||
/* the image size is different that the original and we want to keep the aspect ratio */
|
||||
if( keep_ratio && ( info->width != wanted_w) && ( info->height != wanted_h))
|
||||
{
|
||||
float factor = MAX( ( float)info->height / ( float)wanted_h, ( float)info->width / ( float)wanted_w);
|
||||
precise_x = ( float)info->width / factor;
|
||||
precise_y = ( float)info->height / factor;
|
||||
|
||||
display_w = ( ( uint16)precise_x > 0 ? ( uint16)precise_x : 16);
|
||||
display_h = ( ( uint16)precise_y > 0 ? ( uint16)precise_y : 16);
|
||||
data->IncXfx = ((( uint32)info->width << 16) + ( display_w >> 1)) / display_w;
|
||||
data->IncYfx = ((( uint32)info->height << 16) + ( display_h >> 1)) / display_h;
|
||||
}
|
||||
else if(( info->width != wanted_w) && ( info->height != wanted_h))
|
||||
{
|
||||
float x_factor = ( float)info->width / ( float)wanted_w;
|
||||
float y_factor = ( float)info->height / ( float)wanted_h;
|
||||
precise_x = ( float)info->width / x_factor;
|
||||
precise_y = ( float)info->height / y_factor;
|
||||
|
||||
display_w = ( ( uint16)precise_x > 0 ? ( uint16)precise_x : 16);
|
||||
display_h = ( ( uint16)precise_y > 0 ? ( uint16)precise_y : 16);
|
||||
data->IncXfx = ((( uint32)info->width << 16) + ( display_w >> 1)) / display_w;
|
||||
data->IncYfx = ((( uint32)info->height << 16) + ( display_h >> 1)) / display_h;
|
||||
}
|
||||
else
|
||||
{
|
||||
display_w = info->width;
|
||||
display_h = info->height;
|
||||
data->IncXfx = 0x10000uL;
|
||||
data->IncYfx = 0x10000uL;
|
||||
}
|
||||
|
||||
image = init_img( info->page, display_w, display_h, n_planes);
|
||||
|
||||
if( image == NULL)
|
||||
return NULL;
|
||||
|
||||
/* we assume that the pixel size is minimum 8 bits because some GNU libraries return 1 and 4 bits format like 8 bits ones.
|
||||
We add also a little more memory for avoid buffer overflow for plugin badly coded. */
|
||||
src_line_size = ( info->width + 64) * info->components;
|
||||
|
||||
data->RowBuf = ( uint8*)shared_malloc( src_line_size);
|
||||
|
||||
if( !data->RowBuf)
|
||||
return NULL;
|
||||
|
||||
if(( info->planes == 1 && info->components == 1) || nplanes > 8)
|
||||
data->DthBuf = NULL;
|
||||
else
|
||||
{
|
||||
size_t size = ( display_w + 15) * 3;
|
||||
|
||||
data->DthBuf = shared_malloc( size);
|
||||
|
||||
if( data->DthBuf == NULL)
|
||||
return NULL;
|
||||
|
||||
memset( data->DthBuf, 0, size);
|
||||
}
|
||||
|
||||
data->DthWidth = display_w;
|
||||
data->PixMask = ( 1 << info->planes) - 1;
|
||||
data->LnSize = image->image[0].fd_wdwidth * n_planes;
|
||||
|
||||
if ( info->planes == 1 && info->components == 1)
|
||||
{
|
||||
cnvpal_mono( info, data);
|
||||
raster = raster_mono;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( info->indexed_color)
|
||||
{
|
||||
( *cnvpal_color)( info, data);
|
||||
raster = raster_cmap;
|
||||
}
|
||||
else
|
||||
raster = ( info->components >= 3 ? raster_true : raster_gray);
|
||||
}
|
||||
|
||||
image->delay = NULL;
|
||||
|
||||
return image;
|
||||
}
|
||||
|
||||
static inline void read_img ( IMAGE *img, IMGINFO info, DECDATA data)
|
||||
{
|
||||
uint16 *dst;
|
||||
int16 y_dst, i, y, img_h = info->height;
|
||||
int32 line_size = data->LnSize;
|
||||
uint8 *buf = data->RowBuf;
|
||||
|
||||
for ( i = 0; i < img->page; i++)
|
||||
{
|
||||
uint32 scale = ( data->IncYfx + 1) >> 1;
|
||||
y_dst = img->image[0].fd_h;
|
||||
dst = img->image[i].fd_addr;
|
||||
|
||||
if( info->orientation == DOWN_TO_UP)
|
||||
{
|
||||
dst += data->LnSize * ( y_dst - 1);
|
||||
line_size = -data->LnSize;
|
||||
}
|
||||
|
||||
info->page_wanted = i;
|
||||
|
||||
for( y = 1; y <= img_h; y++)
|
||||
{
|
||||
if( !decoder_read( info, buf))
|
||||
return;
|
||||
|
||||
while(( scale >> 16) < y)
|
||||
{
|
||||
( *raster)( data, dst);
|
||||
dst += line_size;
|
||||
scale += data->IncYfx;
|
||||
if (!--y_dst) break;
|
||||
}
|
||||
}
|
||||
|
||||
if( img->delay != NULL )
|
||||
{
|
||||
img->delay[i] = info->delay;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void quit_img( IMGINFO info, DECDATA data)
|
||||
{
|
||||
if( decoder_init_done == TRUE)
|
||||
decoder_quit( info);
|
||||
|
||||
if( data->DthBuf)
|
||||
shared_free( data->DthBuf);
|
||||
|
||||
if( data->RowBuf)
|
||||
shared_free( data->RowBuf);
|
||||
|
||||
shared_free( data);
|
||||
shared_free( info);
|
||||
|
||||
decoder_init_done = FALSE;
|
||||
}
|
||||
|
||||
|
||||
boolean get_pic_info( const char *file, IMGINFO info)
|
||||
{
|
||||
int16 i, j, c = 0;
|
||||
char extention[3+1], plugin[3];
|
||||
|
||||
strcpy ( extention, file + strlen( file) - 3);
|
||||
str2upper( extention);
|
||||
|
||||
/* We check if a plug-ins can do the job */
|
||||
for( i = 0; i < plugins_nbr; i++, c = 0)
|
||||
{
|
||||
for( j = 0; j < codecs[i]->user_ext; j++)
|
||||
{
|
||||
plugin[0] = codecs[i]->infos[c++];
|
||||
plugin[1] = codecs[i]->infos[c++];
|
||||
plugin[2] = codecs[i]->infos[c++];
|
||||
|
||||
if( strncmp ( extention, plugin, 3) == 0)
|
||||
{
|
||||
if ( !( decoder_init = ldg_find( "reader_init", codecs[i]))
|
||||
|| !( decoder_read = ldg_find( "reader_read", codecs[i]))
|
||||
|| !( decoder_quit = ldg_find( "reader_quit", codecs[i])))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return decoder_init( file, info);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* I wish that it will never append ! */
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
IMAGE *load_img( const char *file, int16 w, int16 h, int16 keep_ratio)
|
||||
{
|
||||
IMGINFO info;
|
||||
DECDATA data;
|
||||
IMAGE *img;
|
||||
|
||||
/* One codec or more must be present */
|
||||
if( codecs[0] == NULL)
|
||||
return( NULL);
|
||||
|
||||
info = ( img_info *)shared_malloc( sizeof( img_info));
|
||||
|
||||
if( !info)
|
||||
return( NULL);
|
||||
|
||||
data = ( dec_data *)shared_malloc( sizeof( dec_data));
|
||||
|
||||
if( !data)
|
||||
{
|
||||
shared_free( info);
|
||||
return ( NULL);
|
||||
}
|
||||
|
||||
info->background_color = 0xFFFFFF;
|
||||
info->thumbnail = FALSE;
|
||||
|
||||
if (( decoder_init_done = get_pic_info( file, info)) == FALSE)
|
||||
{
|
||||
shared_free( data);
|
||||
shared_free( info);
|
||||
return ( NULL);
|
||||
}
|
||||
|
||||
img = setup ( info, data, w, h, keep_ratio);
|
||||
if( img == NULL)
|
||||
{
|
||||
delete_img( img);
|
||||
quit_img( info, data);
|
||||
return ( NULL);
|
||||
}
|
||||
|
||||
read_img ( img, info, data);
|
||||
|
||||
quit_img( info, data);
|
||||
|
||||
return ( img);
|
||||
}
|
||||
92
sources/z-tools/trunk/zcodeclib/src/load_img.h
Normal file
92
sources/z-tools/trunk/zcodeclib/src/load_img.h
Normal file
@@ -0,0 +1,92 @@
|
||||
#define UP_TO_DOWN 0
|
||||
#define DOWN_TO_UP 1
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8 red;
|
||||
uint8 green;
|
||||
uint8 blue;
|
||||
} COLOR_MAP;
|
||||
|
||||
typedef struct _img_info *IMGINFO;
|
||||
|
||||
typedef struct _img_info
|
||||
{
|
||||
/* Data returned by the decoder Picture's initialisation */
|
||||
uint16 width; /* Picture width */
|
||||
uint16 height; /* Picture Height */
|
||||
uint16 components; /* Picture components */
|
||||
uint16 planes; /* Picture bits by pixel */
|
||||
uint32 colors; /* Picture colors number */
|
||||
int16 orientation; /* picture orientation: UP_TO_DOWN or DONW_TO_UP ( ex: TGA) */
|
||||
uint16 page; /* Number of page/image in the file */
|
||||
uint16 delay; /* Animation delay in 200th sec. between each frame. */
|
||||
uint16 num_comments; /* Lines in the file's comment. ( 0 if none) */
|
||||
uint16 max_comments_length; /* The length of the greater line in the comment */
|
||||
int16 indexed_color; /* Picture has a palette: 0) No 1) Yes */
|
||||
int16 memory_alloc; /* where to do the memory allocation for the reader_read
|
||||
function buffer, possible values are ST_RAM or TT_RAM */
|
||||
COLOR_MAP palette[256]; /* Palette in standard RGB format */
|
||||
|
||||
|
||||
/* data send to the codec */
|
||||
uint32 background_color; /* The wanted background's color in hexa */
|
||||
int16 thumbnail; /* 1 if true else 0.
|
||||
Some format have thumbnail inside the picture, if 1, we
|
||||
want only this thumbnail and not the image itself */
|
||||
uint16 page_wanted; /* The wanted page to get for the reader_read() function
|
||||
The first page is 0 and the last is img_info->page - 1 */
|
||||
|
||||
|
||||
/* The following variable are only for Information Prupose, the zview doesn't
|
||||
use it for decoding routine but only for the information dialog */
|
||||
int8 info[40]; /* Picture's info, for ex: "Gif 87a" */
|
||||
int8 compression[5]; /* Compression type, ex: "LZW" */
|
||||
uint16 real_width; /* Real picture width( if the thumbnail variable is 1) */
|
||||
uint16 real_height; /* Ral picture Height( if the thumbnail variable is 1) */
|
||||
|
||||
|
||||
/* Private data for the plugin */
|
||||
void *_priv_ptr;
|
||||
void *_priv_ptr_more;
|
||||
void *__priv_ptr_more;
|
||||
|
||||
int32 _priv_var;
|
||||
int32 _priv_var_more;
|
||||
|
||||
} img_info;
|
||||
|
||||
|
||||
typedef struct _dec_data *DECDATA;
|
||||
|
||||
typedef struct _dec_data
|
||||
{
|
||||
uint8 *RowBuf;
|
||||
void *DthBuf;
|
||||
uint8 *DstBuf;
|
||||
uint16 DthWidth;
|
||||
uint16 PixMask;
|
||||
int32 LnSize;
|
||||
uint32 IncXfx;
|
||||
uint32 IncYfx;
|
||||
uint32 Pixel[256];
|
||||
} dec_data;
|
||||
|
||||
|
||||
|
||||
typedef struct _img
|
||||
{
|
||||
int16 page; /* Number of page/image in the file */
|
||||
uint16 *delay; /* Animation delay in millise. between each frame */
|
||||
MFDB *image; /* The Image itself */
|
||||
}IMAGE;
|
||||
|
||||
extern void ( *raster) ( DECDATA, void *dst);
|
||||
extern void ( *raster_cmap) ( DECDATA, void *);
|
||||
extern void ( *raster_true) ( DECDATA, void *);
|
||||
extern void ( *cnvpal_color)( IMGINFO, DECDATA);
|
||||
extern void ( *raster_gray) ( DECDATA, void *);
|
||||
|
||||
extern IMAGE *load_img( const char *file, int16 w, int16 h, int16 keep_ratio);
|
||||
|
||||
55
sources/z-tools/trunk/zcodeclib/src/mem.c
Normal file
55
sources/z-tools/trunk/zcodeclib/src/mem.c
Normal file
@@ -0,0 +1,55 @@
|
||||
#include "general.h"
|
||||
|
||||
/* Prototype */
|
||||
void mem_quit( void);
|
||||
int16 mem_init( void);
|
||||
|
||||
LDG *ldg_mem = NULL;
|
||||
|
||||
/*==================================================================================*
|
||||
* int16 mem_init: *
|
||||
* Initialise the memory manager. *
|
||||
*----------------------------------------------------------------------------------*
|
||||
* input: *
|
||||
* -- *
|
||||
*----------------------------------------------------------------------------------*
|
||||
* returns: *
|
||||
* '1' if all is OK else '0' *
|
||||
*==================================================================================*/
|
||||
|
||||
int16 mem_init( void)
|
||||
{
|
||||
ldg_mem = ldg_open( "C:\\gemsys\\ldg\\mem.ldg", ldg_global);
|
||||
|
||||
if( !ldg_mem)
|
||||
ldg_mem = ldg_open( "mem.ldg", ldg_global);
|
||||
|
||||
_ldg_malloc = ldg_find( "ldg_malloc", ldg_mem);
|
||||
_ldg_free = ldg_find( "ldg_free", ldg_mem);
|
||||
_ldg_allocmode = ldg_find( "ldg_allocmode", ldg_mem);
|
||||
|
||||
if ( !ldg_mem || !_ldg_malloc || !_ldg_free || !_ldg_allocmode)
|
||||
return( 0);
|
||||
|
||||
ldg_allocmode( 0L);
|
||||
|
||||
return( 1);
|
||||
}
|
||||
|
||||
|
||||
/*==================================================================================*
|
||||
* void mem_quit: *
|
||||
* close the memory manager. *
|
||||
*----------------------------------------------------------------------------------*
|
||||
* input: *
|
||||
* -- *
|
||||
*----------------------------------------------------------------------------------*
|
||||
* returns: *
|
||||
* -- *
|
||||
*==================================================================================*/
|
||||
void mem_quit( void)
|
||||
{
|
||||
if( ldg_mem)
|
||||
ldg_close( ldg_mem, ldg_global);
|
||||
}
|
||||
|
||||
4
sources/z-tools/trunk/zcodeclib/src/mem.h
Normal file
4
sources/z-tools/trunk/zcodeclib/src/mem.h
Normal file
@@ -0,0 +1,4 @@
|
||||
extern int16 mem_init( void);
|
||||
extern void mem_quit( void);
|
||||
|
||||
|
||||
71
sources/z-tools/trunk/zcodeclib/src/mfdb.c
Normal file
71
sources/z-tools/trunk/zcodeclib/src/mfdb.c
Normal file
@@ -0,0 +1,71 @@
|
||||
#include "general.h"
|
||||
|
||||
|
||||
/* Prototype */
|
||||
int16 init_mfdb( MFDB *bm, int16 width, int16 height, int16 planes);
|
||||
void delete_mfdb( MFDB *bm, int16 nbr);
|
||||
|
||||
|
||||
/*==================================================================================*
|
||||
* int16 init_mfdb: *
|
||||
* fit a MFDB with the parameters suppplied. *
|
||||
*----------------------------------------------------------------------------------*
|
||||
* input: *
|
||||
* bm -> The MFDB to fit. *
|
||||
* width -> Image's width. *
|
||||
* height -> Image's height. *
|
||||
* planes -> Screen planes or 1 if the image is monochrome. *
|
||||
*----------------------------------------------------------------------------------*
|
||||
* returns: *
|
||||
* '0' if error or the memory size allocated. *
|
||||
*==================================================================================*/
|
||||
int16 init_mfdb( MFDB *bm, int16 width, int16 height, int16 planes)
|
||||
{
|
||||
uint32 length;
|
||||
|
||||
bm->fd_w = width;
|
||||
bm->fd_h = height;
|
||||
bm->fd_wdwidth = ( width >> 4) + (( width % 16) != 0);
|
||||
bm->fd_stand = 0;
|
||||
bm->fd_nplanes = planes;
|
||||
bm->fd_r1 = 0;
|
||||
bm->fd_r2 = 0;
|
||||
bm->fd_r3 = 0;
|
||||
|
||||
length = (( (( uint32)bm->fd_wdwidth << 1 ) * ( uint32)bm->fd_nplanes) * ( uint32)bm->fd_h) + 256L;
|
||||
bm->fd_addr = shared_malloc( length);
|
||||
|
||||
if ( bm->fd_addr)
|
||||
return ( 1);
|
||||
else
|
||||
return ( 0);
|
||||
}
|
||||
|
||||
|
||||
/*==================================================================================*
|
||||
* int16 delete_mfdb: *
|
||||
* free the data of MFDB struct. *
|
||||
*----------------------------------------------------------------------------------*
|
||||
* input: *
|
||||
* bm -> pointer to the MFDB to delete. *
|
||||
* nbr -> The number of MFDB struct. to delete. *
|
||||
*----------------------------------------------------------------------------------*
|
||||
* returns: *
|
||||
* -- *
|
||||
*==================================================================================*/
|
||||
void delete_mfdb( MFDB *bm, int16 nbr)
|
||||
{
|
||||
register int16 i;
|
||||
|
||||
if( nbr == 0 || bm == NULL)
|
||||
return;
|
||||
|
||||
for ( i = 0; i < nbr; i++)
|
||||
{
|
||||
if ( bm[i].fd_addr)
|
||||
shared_free( bm[i].fd_addr);
|
||||
}
|
||||
|
||||
shared_free( bm);
|
||||
}
|
||||
|
||||
2
sources/z-tools/trunk/zcodeclib/src/mfdb.h
Normal file
2
sources/z-tools/trunk/zcodeclib/src/mfdb.h
Normal file
@@ -0,0 +1,2 @@
|
||||
extern int16 init_mfdb( MFDB *bm, int16 width, int16 height, int16 planes);
|
||||
extern void delete_mfdb( MFDB *bm, int16 nbr);
|
||||
156
sources/z-tools/trunk/zcodeclib/src/resize.c
Normal file
156
sources/z-tools/trunk/zcodeclib/src/resize.c
Normal file
@@ -0,0 +1,156 @@
|
||||
#include "general.h"
|
||||
#include "load_img.h"
|
||||
#include "mfdb.h"
|
||||
#include "zvdi/raresize.h"
|
||||
#include "zvdi/vdi.h"
|
||||
#include "zvdi/p2c.h"
|
||||
|
||||
|
||||
void ( *resize)( DECDATA, void *dst);
|
||||
void ( *my_resize)( DECDATA, void *dst);
|
||||
|
||||
extern int32 plane2packed( int32 no_words, int32 plane_length, int16 no_planes, void *src, void *dst);
|
||||
|
||||
|
||||
static int16 resize_setup( MFDB *in, MFDB *out, DECDATA data, int16 w, int16 h, int16 keep_ratio)
|
||||
{
|
||||
uint16 display_w, display_h;
|
||||
float precise_x, precise_y;
|
||||
|
||||
/* the image size is different that the original and we want to keep the aspect ratio */
|
||||
if( keep_ratio)
|
||||
{
|
||||
float factor = MAX( ( float)in->fd_h / ( float)h, ( float)in->fd_w / ( float)w);
|
||||
precise_x = ( float)in->fd_w / factor;
|
||||
precise_y = ( float)in->fd_h / factor;
|
||||
|
||||
display_w = ( ( uint16)precise_x > 0 ? ( uint16)precise_x : 16);
|
||||
display_h = ( ( uint16)precise_y > 0 ? ( uint16)precise_y : 16);
|
||||
data->IncXfx = ((( uint32)in->fd_w << 16) + ( display_w >> 1)) / display_w;
|
||||
data->IncYfx = ((( uint32)in->fd_h << 16) + ( display_h >> 1)) / display_h;
|
||||
}
|
||||
else
|
||||
{
|
||||
float x_factor = ( float)in->fd_w / ( float)w;
|
||||
float y_factor = ( float)in->fd_h / ( float)h;
|
||||
precise_x = ( float)in->fd_w / x_factor;
|
||||
precise_y = ( float)in->fd_h / y_factor;
|
||||
|
||||
display_w = ( ( uint16)precise_x > 0 ? ( uint16)precise_x : 16);
|
||||
display_h = ( ( uint16)precise_y > 0 ? ( uint16)precise_y : 16);
|
||||
data->IncXfx = ((( uint32)in->fd_w << 16) + ( display_w >> 1)) / display_w;
|
||||
data->IncYfx = ((( uint32)in->fd_h << 16) + ( display_h >> 1)) / display_h;
|
||||
}
|
||||
|
||||
if ( !init_mfdb( out, display_w, display_h, in->fd_nplanes))
|
||||
return ( 0);
|
||||
|
||||
data->RowBuf = in->fd_addr;
|
||||
|
||||
if( planar)
|
||||
{
|
||||
data->DstBuf = shared_malloc((( uint32)in->fd_wdwidth << 4 ) + 256uL);
|
||||
|
||||
if( data->DstBuf == NULL)
|
||||
{
|
||||
delete_mfdb( out, 1);
|
||||
return ( 0);
|
||||
}
|
||||
}
|
||||
else
|
||||
data->DstBuf = NULL;
|
||||
|
||||
data->DthWidth = display_w;
|
||||
data->LnSize = out->fd_wdwidth * out->fd_nplanes;
|
||||
|
||||
if( out->fd_nplanes == 1)
|
||||
my_resize = resize_mono;
|
||||
else
|
||||
my_resize = resize;
|
||||
|
||||
return( 1);
|
||||
}
|
||||
|
||||
|
||||
static inline void resize_img( MFDB *in, MFDB *out, DECDATA data)
|
||||
{
|
||||
uint16 *dst = out->fd_addr;
|
||||
int16 y = 0;
|
||||
int32 in_line_size = (( uint32)in->fd_wdwidth << 1 ) * ( uint32)in->fd_nplanes,
|
||||
out_line_size = data->LnSize;
|
||||
uint32 scale = ( data->IncYfx + 1) >> 1;
|
||||
int16 y_dst = out->fd_h;
|
||||
|
||||
|
||||
while ( y < in->fd_h)
|
||||
{
|
||||
y++;
|
||||
|
||||
if( planar)
|
||||
{
|
||||
if( ( scale >> 16) < y)
|
||||
planar_to_chunky( data->RowBuf, data->DstBuf, in->fd_w);
|
||||
}
|
||||
|
||||
while (( scale >> 16) < y)
|
||||
{
|
||||
my_resize( data, dst);
|
||||
dst += out_line_size;
|
||||
scale += data->IncYfx;
|
||||
if ( !--y_dst) break;
|
||||
}
|
||||
|
||||
data->RowBuf += in_line_size;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*==================================================================================*
|
||||
* pic_resize: *
|
||||
* Create a resized MFDB. *
|
||||
*----------------------------------------------------------------------------------*
|
||||
* in: The src MFDB. *
|
||||
* img: The target MFDB. *
|
||||
*----------------------------------------------------------------------------------*
|
||||
* returns: '0' if error else 1. *
|
||||
*==================================================================================*/
|
||||
|
||||
MFDB *pic_resize( MFDB *in, int16 w, int16 h, int16 keep_ratio)
|
||||
{
|
||||
DECDATA data;
|
||||
MFDB *out;
|
||||
|
||||
/* 2 planes zoom not available */
|
||||
if( in->fd_nplanes == 2)
|
||||
return NULL;
|
||||
|
||||
out = ( MFDB *)shared_malloc( sizeof( MFDB));
|
||||
|
||||
if( out == NULL)
|
||||
return NULL;
|
||||
|
||||
data = ( dec_data *)shared_malloc( sizeof( dec_data));
|
||||
|
||||
if( !data)
|
||||
{
|
||||
shared_free( out);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
if( !resize_setup( in, out, data, w, h, keep_ratio))
|
||||
{
|
||||
shared_free( data);
|
||||
shared_free( out);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
resize_img ( in, out, data);
|
||||
|
||||
if( data->DstBuf)
|
||||
shared_free( data->DstBuf);
|
||||
|
||||
shared_free( data);
|
||||
|
||||
return( out);
|
||||
}
|
||||
3
sources/z-tools/trunk/zcodeclib/src/resize.h
Normal file
3
sources/z-tools/trunk/zcodeclib/src/resize.h
Normal file
@@ -0,0 +1,3 @@
|
||||
extern void ( *resize)( DECDATA, void *dst);
|
||||
extern MFDB *pic_resize( MFDB *in, int16 w, int16 h, int16 keep_ratio);
|
||||
|
||||
78
sources/z-tools/trunk/zcodeclib/src/ztext.c
Normal file
78
sources/z-tools/trunk/zcodeclib/src/ztext.c
Normal file
@@ -0,0 +1,78 @@
|
||||
#include "general.h"
|
||||
|
||||
|
||||
/* Local variable */
|
||||
typedef struct
|
||||
{
|
||||
char upper;
|
||||
char lower;
|
||||
} CUL;
|
||||
|
||||
|
||||
static CUL c[] = { {'A', 'a'}, {'B', 'b'}, {'C', 'c'}, {'D', 'd'}, {'E', 'e'}, {'F', 'f'}, {'G', 'g'}, {'H', 'h'},
|
||||
{'I', 'i'}, {'J', 'j'}, {'K', 'k'}, {'L', 'l'}, {'M', 'm'}, {'N', 'n'}, {'O', 'o'}, {'P', 'p'},
|
||||
{'Q', 'q'}, {'R', 'r'}, {'S', 's'}, {'T', 't'}, {'U', 'u'}, {'V', 'v'}, {'W', 'w'}, {'X', 'x'},
|
||||
{'Y', 'y'}, {'Z', 'z'}, {'<EFBFBD>', '<EFBFBD>'}, {'<EFBFBD>', '<EFBFBD>'}, {'<EFBFBD>', '<EFBFBD>'}, {0xb6, '<EFBFBD>'}, {'<EFBFBD>', '<EFBFBD>'}, {'<EFBFBD>', '<EFBFBD>'},
|
||||
{'<EFBFBD>', '<EFBFBD>'}, {'<EFBFBD>', '<EFBFBD>'}, {'<EFBFBD>', '<EFBFBD>'}, {0xb7, 0xb0}, {0xb8, 0xb1}, {0xb2, 0xb3}, {0xb5, 0xb4} };
|
||||
|
||||
|
||||
/* Prototype */
|
||||
void str2lower(char *str);
|
||||
void str2upper(char *str);
|
||||
|
||||
|
||||
/*==================================================================================*
|
||||
* str2lower: *
|
||||
* Transforms all letters in the string to lower case. *
|
||||
*----------------------------------------------------------------------------------*
|
||||
* returns: - *
|
||||
*----------------------------------------------------------------------------------*
|
||||
* str: Pointer to null terminated string. *
|
||||
*==================================================================================*/
|
||||
void str2lower(char *str)
|
||||
{
|
||||
int16 i, k;
|
||||
|
||||
i = 0;
|
||||
while (str[i] != '\0')
|
||||
{
|
||||
for (k = 0; k < (sizeof(c) / sizeof(CUL)); k++)
|
||||
{
|
||||
if (c[k].upper == str[i])
|
||||
{
|
||||
str[i] = c[k].lower;
|
||||
break;
|
||||
}
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*==================================================================================*
|
||||
* str2upper: *
|
||||
* Transforms all letters in the string to uper case. *
|
||||
*----------------------------------------------------------------------------------*
|
||||
* returns: - *
|
||||
*----------------------------------------------------------------------------------*
|
||||
* str: Pointer to null terminated string. *
|
||||
*==================================================================================*/
|
||||
void str2upper(char *str)
|
||||
{
|
||||
int16 i, k;
|
||||
|
||||
i = 0;
|
||||
while (str[i] != '\0')
|
||||
{
|
||||
for (k = 0; k < (sizeof(c) / sizeof(CUL)); k++)
|
||||
{
|
||||
if (c[k].lower == str[i])
|
||||
{
|
||||
str[i] = c[k].upper;
|
||||
break;
|
||||
}
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
5
sources/z-tools/trunk/zcodeclib/src/ztext.h
Normal file
5
sources/z-tools/trunk/zcodeclib/src/ztext.h
Normal file
@@ -0,0 +1,5 @@
|
||||
extern void size_to_text( char *txt, float size);
|
||||
extern void str2lower(char *str);
|
||||
extern void str2upper(char *str);
|
||||
extern int16 name_shorter( int16 handle, int16 max_size, char *str);
|
||||
extern char *zstrncpy( char *dst, const char *src, size_t n);
|
||||
200
sources/z-tools/trunk/zcodeclib/src/zvdi/color.c
Normal file
200
sources/z-tools/trunk/zcodeclib/src/zvdi/color.c
Normal file
@@ -0,0 +1,200 @@
|
||||
#ifdef __PUREC__
|
||||
#include "..\general.h"
|
||||
#include "..\load_img.h"
|
||||
#else
|
||||
#include "../general.h"
|
||||
#include "../load_img.h"
|
||||
#endif
|
||||
#include "vdi.h"
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8 satur;
|
||||
uint8 red, green, blue;
|
||||
} SRGB;
|
||||
|
||||
static SRGB screen_colortab[256];
|
||||
|
||||
|
||||
/* prototype */
|
||||
void save_colors(void);
|
||||
int16 remap_color (int32 value);
|
||||
uint32 color_lookup ( uint32 rgb, int16 *trans);
|
||||
void cnvpal_mono ( IMGINFO info, DECDATA data);
|
||||
void cnvpal_1_2 (IMGINFO info, DECDATA data);
|
||||
void cnvpal_4_8( IMGINFO info, DECDATA data);
|
||||
void cnvpal_15( IMGINFO info, DECDATA data);
|
||||
void cnvpal_high( IMGINFO info, DECDATA data);
|
||||
void cnvpal_true( IMGINFO info, DECDATA data);
|
||||
|
||||
|
||||
static uint8 saturation (uint8 * rgb)
|
||||
{
|
||||
uint8 satr;
|
||||
|
||||
if (rgb[0] >= rgb[1])
|
||||
{
|
||||
if (rgb[1] >= rgb[2])
|
||||
satr = rgb[0] - rgb[2];
|
||||
else if (rgb[0] > rgb[2])
|
||||
satr = rgb[0] - rgb[1];
|
||||
else
|
||||
satr = rgb[2] - rgb[1];
|
||||
}
|
||||
else if (rgb[1] >= rgb[2])
|
||||
{
|
||||
if (rgb[0] >= rgb[2])
|
||||
satr = rgb[1] - rgb[2];
|
||||
else
|
||||
satr = rgb[1] - rgb[0];
|
||||
}
|
||||
else
|
||||
satr = rgb[2] - rgb[0];
|
||||
|
||||
return satr;
|
||||
}
|
||||
|
||||
|
||||
void save_colors(void)
|
||||
{
|
||||
register int16 i;
|
||||
int16 colors = 1 << nplanes;
|
||||
|
||||
for( i = 0; i < colors; i++)
|
||||
{
|
||||
int16 coltab[3];
|
||||
|
||||
vq_color( vdi_handle, i, 1, coltab);
|
||||
|
||||
screen_colortab[i].red = ((((int32)coltab[0] << 8 ) - coltab[0]) + 500) / 1000;
|
||||
screen_colortab[i].green = ((((int32)coltab[1] << 8 ) - coltab[1]) + 500) / 1000;
|
||||
screen_colortab[i].blue = ((((int32)coltab[2] << 8 ) - coltab[2]) + 500) / 1000;
|
||||
screen_colortab[i].satur = saturation ( &screen_colortab[i].red);
|
||||
}
|
||||
}
|
||||
|
||||
int16 remap_color (int32 value)
|
||||
{
|
||||
int16 red = ((uint8*)&value)[1];
|
||||
int16 green = ((uint8*)&value)[2];
|
||||
int16 blue = ((uint8*)&value)[3];
|
||||
int16 satur = saturation (((uint8*)&value) +1);
|
||||
|
||||
int16 best_fit = 0;
|
||||
uint16 best_err = 0xFFFFu;
|
||||
int16 max_color = 1 << nplanes;
|
||||
|
||||
int16 i = 0;
|
||||
|
||||
value = ( value & 0x00FFFFFFl) | (( int32)satur << 24);
|
||||
|
||||
do
|
||||
{
|
||||
if ( *( int32*)&screen_colortab[i] == value)
|
||||
{
|
||||
/* gotcha! */
|
||||
best_fit = i;
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
uint16 err =
|
||||
( red > screen_colortab[i].red ? red - screen_colortab[i].red : screen_colortab[i].red - red)
|
||||
+ (green > screen_colortab[i].green ? green - screen_colortab[i].green : screen_colortab[i].green - green)
|
||||
+ (blue > screen_colortab[i].blue ? blue - screen_colortab[i].blue : screen_colortab[i].blue - blue)
|
||||
+ (satur > screen_colortab[i].satur ? satur - screen_colortab[i].satur : screen_colortab[i].satur - satur);
|
||||
|
||||
if (err <= best_err)
|
||||
{
|
||||
best_err = err;
|
||||
best_fit = i;
|
||||
}
|
||||
}
|
||||
} while (++i < max_color);
|
||||
|
||||
return best_fit;
|
||||
}
|
||||
|
||||
|
||||
uint32 color_lookup ( uint32 rgb, int16 *trans)
|
||||
{
|
||||
uint8 idx = ((rgb & ~0xFFuL) == ~0xFFuL ? rgb : remap_color (rgb));
|
||||
return ( (( int32)(trans ? trans[idx] : idx) << 24) | (*(int32*)&screen_colortab[idx] & 0x00FFFFFFuL));
|
||||
}
|
||||
|
||||
|
||||
void cnvpal_mono ( IMGINFO info, DECDATA data)
|
||||
{
|
||||
/* if ( info->indexed_color)
|
||||
{
|
||||
uint32 bgnd, fgnd;
|
||||
|
||||
bgnd = (((( int32)info->palette[0].red <<8) | info->palette[0].green) <<8) | info->palette[0].blue;
|
||||
fgnd = (((( int32)info->palette[1].red <<8) | info->palette[1].green) <<8) | info->palette[1].blue;
|
||||
|
||||
data->Pixel[0] = remap_color ( bgnd);
|
||||
data->Pixel[1] = remap_color ( fgnd);
|
||||
|
||||
}
|
||||
else
|
||||
*/ {
|
||||
data->Pixel[0] = G_WHITE;
|
||||
data->Pixel[1] = G_BLACK;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void cnvpal_1_2 (IMGINFO info, DECDATA data)
|
||||
{
|
||||
register int32 i;
|
||||
|
||||
for( i = 0; i < info->colors; i++)
|
||||
{
|
||||
data->Pixel[i] = ( int16)info->palette[i].red * 5 + ( int16)info->palette[i].green * 9 + (( int16)info->palette[i].blue << 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void cnvpal_4_8( IMGINFO info, DECDATA data)
|
||||
{
|
||||
register int32 i;
|
||||
|
||||
for( i = 0; i < info->colors; i++)
|
||||
{
|
||||
uint32 rgb = (((( int32)info->palette[i].red << 8) | info->palette[i].green) << 8) | info->palette[i].blue;
|
||||
data->Pixel[i] = rgb | (( int32)pixel_val[remap_color ( rgb)] << 24);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void cnvpal_15( IMGINFO info, DECDATA data)
|
||||
{
|
||||
register int32 i;
|
||||
|
||||
for( i = 0; i < info->colors; i++)
|
||||
{
|
||||
data->Pixel[i] = (( int16)( info->palette[i].red & 0xF8) << 7) | (( int16)( info->palette[i].green & 0xF8) << 2) | ( info->palette[i].blue >> 3);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void cnvpal_high( IMGINFO info, DECDATA data)
|
||||
{
|
||||
register int32 i;
|
||||
|
||||
for( i = 0; i < info->colors; i++)
|
||||
{
|
||||
data->Pixel[i] = (( int16)( info->palette[i].red & 0xF8) << 8) | (( int16)( info->palette[i].green & 0xFC) << 3) | ( info->palette[i].blue >> 3);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void cnvpal_true ( IMGINFO info, DECDATA data)
|
||||
{
|
||||
register int32 i;
|
||||
|
||||
for( i = 0; i < info->colors; i++)
|
||||
{
|
||||
data->Pixel[i] = (((( int32)info->palette[i].red << 8) | info->palette[i].green) << 8) | info->palette[i].blue;
|
||||
}
|
||||
}
|
||||
14
sources/z-tools/trunk/zcodeclib/src/zvdi/color.h
Normal file
14
sources/z-tools/trunk/zcodeclib/src/zvdi/color.h
Normal file
@@ -0,0 +1,14 @@
|
||||
extern void save_colors( void);
|
||||
extern int16 remap_color( int32 value);
|
||||
|
||||
extern uint32 color_lookup( uint32 rgb, int16 *trans);
|
||||
|
||||
extern void cnvpal_mono( IMGINFO info, DECDATA data);
|
||||
extern void cnvpal_1_2( IMGINFO info, DECDATA data);
|
||||
extern void cnvpal_4_8( IMGINFO info, DECDATA data);
|
||||
extern void cnvpal_15( IMGINFO info, DECDATA data);
|
||||
extern void cnvpal_high( IMGINFO info, DECDATA data);
|
||||
extern void cnvpal_true( IMGINFO info, DECDATA data);
|
||||
|
||||
extern void ( *cnvpal_color)( IMGINFO, DECDATA);
|
||||
|
||||
46
sources/z-tools/trunk/zcodeclib/src/zvdi/dither.c
Normal file
46
sources/z-tools/trunk/zcodeclib/src/zvdi/dither.c
Normal file
@@ -0,0 +1,46 @@
|
||||
#ifdef __PUREC__
|
||||
#include "..\general.h"
|
||||
#else
|
||||
#include "../general.h"
|
||||
#endif
|
||||
|
||||
|
||||
extern uint32 cube216[216];
|
||||
extern uint32 graymap[32];
|
||||
|
||||
/* prototype */
|
||||
inline uint8 dither_true ( uint8 * rgb, int16 * err, int8 ** buf);
|
||||
inline uint8 dither_gray( uint8 *gray, int16 *err, int8 **buf);
|
||||
|
||||
inline uint8 dither_true ( uint8 * rgb, int16 * err, int8 ** buf)
|
||||
{
|
||||
int8 *dth = *buf;
|
||||
unsigned short r = (( err[0] += ( int16)dth[0] + rgb[0]) <= 42 ? 0 : err[0] >= 213 ? 5 : ( err[0] * 3) >> 7);
|
||||
unsigned short g = (( err[1] += ( int16)dth[1] + rgb[1]) <= 42 ? 0 : err[1] >= 213 ? 5 : ( err[1] * 3) >> 7);
|
||||
unsigned short b = (( err[2] += ( int16)dth[2] + rgb[2]) <= 42 ? 0 : err[2] >= 213 ? 5 : ( err[2] * 3) >> 7);
|
||||
uint8 * irgb = ( uint8*)&cube216[( r * 6 + g) * 6 + b];
|
||||
|
||||
err[0] -= irgb[1];
|
||||
dth[0] = ( err[0] <= -254 ? ( err[0] =- 127) : err[0] >= +254 ? ( err[0] =+ 127) : ( err[0] >>= 1));
|
||||
err[1] -= irgb[2];
|
||||
dth[1] = ( err[1] <= -254 ? ( err[1] =- 127) : err[1] >= +254 ? ( err[1] =+ 127) : ( err[1] >>= 1));
|
||||
err[2] -= irgb[3];
|
||||
dth[2] = ( err[2] <= -254 ? ( err[2] = -127) : err[2] >= +254 ? ( err[2] = +127) : ( err[2] >>= 1));
|
||||
( *buf) += 3;
|
||||
|
||||
return irgb[0];
|
||||
}
|
||||
|
||||
|
||||
inline uint8 dither_gray( uint8 *gray, int16 *err, int8 **buf)
|
||||
{
|
||||
int8 *dth = *buf;
|
||||
unsigned short idx = (( err[0] += ( int16)dth[0] + gray[0]) <= 0x07 ? 0 : err[0] >= 0xF8 ? 0x1F : err[0] >> 3);
|
||||
uint8 *irgb = ( uint8*)&graymap[idx];
|
||||
|
||||
err[0] -= irgb[1];
|
||||
dth[0] = ( err[0] <= -254 ? ( err[0] = -127) : err[0] >= +254 ? ( err[0] =+ 127) : ( err[0] >>= 1));
|
||||
(*buf) += 1;
|
||||
|
||||
return irgb[0];
|
||||
}
|
||||
2
sources/z-tools/trunk/zcodeclib/src/zvdi/dither.h
Normal file
2
sources/z-tools/trunk/zcodeclib/src/zvdi/dither.h
Normal file
@@ -0,0 +1,2 @@
|
||||
extern inline uint8 dither_true ( uint8 * rgb, int16 * err, int8 ** buf);
|
||||
extern inline uint8 dither_gray( uint8 *gray, int16 *err, int8 **buf);
|
||||
87
sources/z-tools/trunk/zcodeclib/src/zvdi/p2c.c
Normal file
87
sources/z-tools/trunk/zcodeclib/src/zvdi/p2c.c
Normal file
@@ -0,0 +1,87 @@
|
||||
#ifdef __PUREC__
|
||||
#include "..\general.h"
|
||||
#else
|
||||
#include "../general.h"
|
||||
#endif
|
||||
|
||||
|
||||
void ( *planar_to_chunky)( uint8 *in, uint8 *out, int16 width);
|
||||
|
||||
|
||||
inline void planar8_to_chunky8( uint8 *in, uint8 *out, int16 width)
|
||||
{
|
||||
uint8 *l;
|
||||
uint16 x, c, p0, p1, p2, p3, p4, p5, p6, p7;
|
||||
|
||||
for( x = 0, l = in; x < width; l += 16)
|
||||
{
|
||||
p0 = ( l[0] << 8) | l[1];
|
||||
p1 = ( l[2] << 8) | l[3];
|
||||
p2 = ( l[4] << 8) | l[5];
|
||||
p3 = ( l[6] << 8) | l[7];
|
||||
p4 = ( l[8] << 8) | l[9];
|
||||
p5 = ( l[10] << 8) | l[11];
|
||||
p6 = ( l[12] << 8) | l[13];
|
||||
p7 = ( l[14] << 8) | l[15];
|
||||
|
||||
for ( c = 0; c < 16; c++)
|
||||
{
|
||||
out[x++] = ((p0 >> 15) & 1) | ((p1 >> 14) & 2) | ((p2 >> 13) & 4) | ((p3 >> 12) & 8) |
|
||||
((p4 >> 11) & 16) | ((p5 >> 10) & 32)| ((p6 >> 9) & 64) | ((p7 >> 8) & 128);
|
||||
p0 <<= 1;
|
||||
p1 <<= 1;
|
||||
p2 <<= 1;
|
||||
p3 <<= 1;
|
||||
p4 <<= 1;
|
||||
p5 <<= 1;
|
||||
p6 <<= 1;
|
||||
p7 <<= 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
inline void planar4_to_chunky8( uint8 *in, uint8 *out, int16 width)
|
||||
{
|
||||
uint8 *l;
|
||||
uint16 x, c, p0, p1, p2, p3;
|
||||
|
||||
for( x = 0, l = in; x < width; l += 8)
|
||||
{
|
||||
p0 = ( l[0] << 8) | l[1];
|
||||
p1 = ( l[2] << 8) | l[3];
|
||||
p2 = ( l[4] << 8) | l[5];
|
||||
p3 = ( l[6] << 8) | l[7];
|
||||
|
||||
for ( c = 0; c < 16; c++)
|
||||
{
|
||||
out[x++] = ((p0 >> 15) & 1) | ((p1 >> 14) & 2) | ((p2 >> 13) & 4) | ((p3 >> 12) & 8);
|
||||
|
||||
p0 <<= 1;
|
||||
p1 <<= 1;
|
||||
p2 <<= 1;
|
||||
p3 <<= 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
inline void planar2_to_chunky8( uint8 *in, uint8 *out, int16 width)
|
||||
{
|
||||
uint8 *l;
|
||||
uint16 x, c, p0, p1;
|
||||
|
||||
for ( x = 0, l = in; x < width; l += 4)
|
||||
{
|
||||
p0 = (l[0] << 8) | l[1];
|
||||
p1 = (l[2] << 8) | l[3];
|
||||
|
||||
for (c = 0; c < 16; c++)
|
||||
{
|
||||
out[x++] = ((p0 >> 15) & 1) | ((p1 >> 14) & 2);
|
||||
p0 <<= 1;
|
||||
p1 <<= 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
5
sources/z-tools/trunk/zcodeclib/src/zvdi/p2c.h
Normal file
5
sources/z-tools/trunk/zcodeclib/src/zvdi/p2c.h
Normal file
@@ -0,0 +1,5 @@
|
||||
extern void ( *planar_to_chunky)( uint8 *in, uint8 *out, int16 width);
|
||||
extern void planar8_to_chunky8( uint8 *in, uint8 *out, int16 width);
|
||||
extern void planar4_to_chunky8( uint8 *in, uint8 *out, int16 width);
|
||||
extern void planar2_to_chunky8( uint8 *in, uint8 *out, int16 width);
|
||||
|
||||
152
sources/z-tools/trunk/zcodeclib/src/zvdi/raresize.c
Normal file
152
sources/z-tools/trunk/zcodeclib/src/zvdi/raresize.c
Normal file
@@ -0,0 +1,152 @@
|
||||
#ifdef __PUREC__
|
||||
#include "..\general.h"
|
||||
#include "..\load_img.h"
|
||||
#else
|
||||
#include "../general.h"
|
||||
#include "../load_img.h"
|
||||
#endif
|
||||
#include "dither.h"
|
||||
#include "raster.h"
|
||||
|
||||
inline void resize_mono ( DECDATA info, void * _dst)
|
||||
{
|
||||
uint8 *dst = _dst;
|
||||
int16 width = info->DthWidth;
|
||||
uint32 x = (info->IncXfx + 1) >> 4;
|
||||
uint16 pixel = 0x80, chunk = 0;
|
||||
|
||||
do
|
||||
{
|
||||
chunk |= ( info->RowBuf[x >> 16] & 1);
|
||||
chunk <<= 1;
|
||||
|
||||
if ( !--width || !(pixel >>= 1))
|
||||
{
|
||||
*(dst++) = chunk;
|
||||
chunk = 0;
|
||||
pixel = 0x80;
|
||||
}
|
||||
|
||||
x += ( info->IncXfx >> 3);
|
||||
|
||||
} while ( width);
|
||||
}
|
||||
|
||||
|
||||
inline void resize_I4 ( DECDATA info, void * _dst)
|
||||
{
|
||||
uint16 *dst = _dst;
|
||||
int16 width = info->DthWidth;
|
||||
uint32 x = (info->IncXfx +1) >> 1;
|
||||
uint8 buf[16];
|
||||
int16 n = 16;
|
||||
uint8 *tmp = buf;
|
||||
|
||||
do
|
||||
{
|
||||
*(tmp++) = *( uint8*)&info->DstBuf[x >> 16];
|
||||
|
||||
if (!--width || !--n)
|
||||
{
|
||||
raster_chunk4( buf, dst, tmp - buf);
|
||||
dst += 4;
|
||||
n = 16;
|
||||
tmp = buf;
|
||||
}
|
||||
x += info->IncXfx;
|
||||
|
||||
} while ( width);
|
||||
}
|
||||
|
||||
|
||||
inline void resize_I8 ( DECDATA info, void * _dst)
|
||||
{
|
||||
uint16 *dst = _dst;
|
||||
int16 width = info->DthWidth;
|
||||
uint32 x = (info->IncXfx +1) >> 1;
|
||||
uint8 buf[16];
|
||||
int16 n = 16;
|
||||
uint8 *tmp = buf;
|
||||
|
||||
do
|
||||
{
|
||||
*(tmp++) = *( uint8*)&info->DstBuf[x >> 16];
|
||||
|
||||
if (!--width || !--n)
|
||||
{
|
||||
raster_chunk8 (buf, dst, tmp - buf);
|
||||
dst += 8;
|
||||
n = 16;
|
||||
tmp = buf;
|
||||
}
|
||||
x += info->IncXfx;
|
||||
|
||||
} while (width);
|
||||
}
|
||||
|
||||
|
||||
inline void resize_P8(DECDATA info, void * _dst)
|
||||
{
|
||||
uint8 *dst = _dst;
|
||||
int16 width = info->DthWidth;
|
||||
uint32 x = (info->IncXfx + 1) >> 1;
|
||||
|
||||
do
|
||||
{
|
||||
uint8 *rgb = &info->RowBuf[x >> 16];
|
||||
*(dst++) = *(rgb);
|
||||
x += info->IncXfx;
|
||||
} while (--width);
|
||||
}
|
||||
|
||||
|
||||
inline void resize_16(DECDATA info, void * _dst)
|
||||
{
|
||||
uint8 *dst = _dst;
|
||||
int16 width = info->DthWidth;
|
||||
uint32 x = (info->IncXfx + 1) >> 1;
|
||||
|
||||
do
|
||||
{
|
||||
uint8 *rgb = &info->RowBuf[(x >> 16) << 1];
|
||||
*(dst++) = *(rgb++);
|
||||
*(dst++) = *(rgb);
|
||||
x += info->IncXfx;
|
||||
} while (--width);
|
||||
}
|
||||
|
||||
|
||||
inline void resize_24(DECDATA info, void * _dst)
|
||||
{
|
||||
uint8 *dst = _dst;
|
||||
int16 width = info->DthWidth;
|
||||
uint32 x = (info->IncXfx + 1) >> 1;
|
||||
|
||||
do
|
||||
{
|
||||
uint8 * rgb = &info->RowBuf[(x >>16) * 3];
|
||||
*(dst++) = *(rgb++);
|
||||
*(dst++) = *(rgb++);
|
||||
*(dst++) = *(rgb);
|
||||
x += info->IncXfx;
|
||||
} while (--width);
|
||||
}
|
||||
|
||||
|
||||
inline void resize_32( DECDATA info, void * _dst)
|
||||
{
|
||||
uint8 *dst = _dst;
|
||||
int16 width = info->DthWidth;
|
||||
uint32 x = (info->IncXfx + 1) >> 1;
|
||||
|
||||
do
|
||||
{
|
||||
uint8 * rgb = &info->RowBuf[(x >> 16) << 2];
|
||||
*(dst++) = *(rgb++);
|
||||
*(dst++) = *(rgb++);
|
||||
*(dst++) = *(rgb++);
|
||||
*(dst++) = *(rgb);
|
||||
|
||||
x += info->IncXfx;
|
||||
} while (--width);
|
||||
}
|
||||
8
sources/z-tools/trunk/zcodeclib/src/zvdi/raresize.h
Normal file
8
sources/z-tools/trunk/zcodeclib/src/zvdi/raresize.h
Normal file
@@ -0,0 +1,8 @@
|
||||
extern void resize_mono( DECDATA info, void * _dst);
|
||||
extern void resize_I4( DECDATA info, void * _dst);
|
||||
extern void resize_I8( DECDATA info, void * _dst);
|
||||
extern void resize_P8( DECDATA info, void * _dst);
|
||||
extern void resize_16( DECDATA info, void * _dst);
|
||||
extern void resize_24( DECDATA info, void * _dst);
|
||||
extern void resize_32( DECDATA info, void * _dst);
|
||||
|
||||
877
sources/z-tools/trunk/zcodeclib/src/zvdi/raster.c
Normal file
877
sources/z-tools/trunk/zcodeclib/src/zvdi/raster.c
Normal file
@@ -0,0 +1,877 @@
|
||||
#ifdef __PUREC__
|
||||
#include "..\general.h"
|
||||
#include "..\load_img.h"
|
||||
#else
|
||||
#include "../general.h"
|
||||
#include "../load_img.h"
|
||||
#endif
|
||||
#include "dither.h"
|
||||
#include "raster.h"
|
||||
|
||||
inline void raster_mono ( DECDATA info, void * _dst)
|
||||
{
|
||||
uint16 *dst = _dst;
|
||||
uint32 *map = info->Pixel;
|
||||
int16 width = info->DthWidth;
|
||||
uint32 x = (info->IncXfx + 1) >> 1;
|
||||
uint16 pixel = 0x8000;
|
||||
uint16 chunk = 0;
|
||||
|
||||
do
|
||||
{
|
||||
if ( map[(int16)info->RowBuf[x >>16] & 1])
|
||||
chunk |= pixel;
|
||||
|
||||
if ( !--width || !(pixel >>= 1))
|
||||
{
|
||||
*(dst++) = chunk;
|
||||
chunk = 0;
|
||||
pixel = 0x8000;
|
||||
}
|
||||
x += info->IncXfx;
|
||||
|
||||
} while ( width);
|
||||
}
|
||||
|
||||
inline void raster_D1 ( DECDATA info, void * _dst)
|
||||
{
|
||||
uint16 *dst = _dst;
|
||||
int16 width = info->DthWidth;
|
||||
uint32 x = (info->IncXfx + 1) >> 1;
|
||||
uint32 *map = info->Pixel;
|
||||
uint16 mask = info->PixMask;
|
||||
int16 *buf = info->DthBuf;
|
||||
int16 ins = 0;
|
||||
uint16 pixel = 0x8000;
|
||||
uint16 chunk = 0;
|
||||
|
||||
do
|
||||
{
|
||||
ins += *buf + map[(int16)info->RowBuf[x >>16] & mask];
|
||||
|
||||
if ( ins < 2040)
|
||||
chunk |= pixel;
|
||||
else
|
||||
ins -= 4080;
|
||||
|
||||
*(buf++) = (ins >>= 2);
|
||||
|
||||
if ( !--width || !(pixel >>= 1))
|
||||
{
|
||||
*(dst++) = chunk;
|
||||
chunk = 0;
|
||||
pixel = 0x8000;
|
||||
}
|
||||
x += info->IncXfx;
|
||||
|
||||
} while ( width);
|
||||
}
|
||||
|
||||
inline void gscale_D1( DECDATA info, void * _dst)
|
||||
{
|
||||
uint16 *dst = _dst;
|
||||
int16 width = info->DthWidth;
|
||||
uint32 x = ( info->IncXfx + 1) >> 1;
|
||||
int16 *buf = info->DthBuf;
|
||||
int16 ins = 0;
|
||||
uint16 pixel = 0x8000;
|
||||
uint16 chunk = 0;
|
||||
|
||||
do
|
||||
{
|
||||
ins += *buf + ( int16)info->RowBuf[x >>16];
|
||||
|
||||
if ( ins < 0x80)
|
||||
chunk |= pixel;
|
||||
else
|
||||
ins -= 0xFF;
|
||||
|
||||
*(buf++) = (ins >>= 2);
|
||||
|
||||
if ( !--width || !(pixel >>= 1))
|
||||
{
|
||||
*(dst++) = chunk;
|
||||
chunk = 0;
|
||||
pixel = 0x8000;
|
||||
}
|
||||
x += info->IncXfx;
|
||||
|
||||
} while (width);
|
||||
}
|
||||
|
||||
inline void dither_D1 ( DECDATA info, void * _dst)
|
||||
{
|
||||
uint16 *dst = _dst;
|
||||
int16 width = info->DthWidth;
|
||||
uint32 x = ( info->IncXfx + 1) >> 1;
|
||||
int16 *buf = info->DthBuf;
|
||||
int16 ins = 0;
|
||||
uint16 pixel = 0x8000;
|
||||
uint16 chunk = 0;
|
||||
|
||||
do
|
||||
{
|
||||
uint8 *rgb = &info->RowBuf[(x >>16) *3];
|
||||
ins += *buf + ( int16)rgb[0] * 5 + ( int16)rgb[1] * 9 + ( int16)rgb[2] * 2;
|
||||
|
||||
if (ins < 2040)
|
||||
chunk |= pixel;
|
||||
else
|
||||
ins -= 4080;
|
||||
|
||||
*(buf++) = (ins >>= 2);
|
||||
|
||||
if (!--width || !(pixel >>= 1))
|
||||
{
|
||||
*(dst++) = chunk;
|
||||
chunk = 0;
|
||||
pixel = 0x8000;
|
||||
}
|
||||
x += info->IncXfx;
|
||||
|
||||
} while( width);
|
||||
}
|
||||
|
||||
inline void raster_D2 ( DECDATA info, void * _dst)
|
||||
{
|
||||
uint16 *dst = _dst;
|
||||
int16 width = info->DthWidth;
|
||||
uint32 x = ( info->IncXfx + 1) >> 1;
|
||||
uint32 *map = info->Pixel;
|
||||
uint16 mask = info->PixMask;
|
||||
int16 *buf = info->DthBuf;
|
||||
int16 ins = 0;
|
||||
uint16 pixel = 0x8000;
|
||||
uint16 chunk = 0;
|
||||
|
||||
do
|
||||
{
|
||||
ins += *buf + map[( int16)info->RowBuf[x >>16] & mask];
|
||||
|
||||
if ( ins < 2040)
|
||||
chunk |= pixel;
|
||||
else
|
||||
ins -= 4080;
|
||||
|
||||
*(buf++) = (ins >>= 2);
|
||||
|
||||
if (!--width || !(pixel >>= 1))
|
||||
{
|
||||
*(dst++) = chunk;
|
||||
*(dst++) = chunk;
|
||||
chunk = 0;
|
||||
pixel = 0x8000;
|
||||
}
|
||||
x += info->IncXfx;
|
||||
|
||||
} while ( width);
|
||||
}
|
||||
|
||||
inline void gscale_D2( DECDATA info, void * _dst)
|
||||
{
|
||||
uint16 *dst = _dst;
|
||||
int16 width = info->DthWidth;
|
||||
uint32 x = ( info->IncXfx + 1) >> 1;
|
||||
int16 *buf = info->DthBuf;
|
||||
int16 ins = 0;
|
||||
uint16 pixel = 0x8000;
|
||||
uint16 chunk = 0;
|
||||
|
||||
do
|
||||
{
|
||||
ins += *buf + (short)info->RowBuf[x >>16];
|
||||
|
||||
if (ins < 0x80)
|
||||
chunk |= pixel;
|
||||
else
|
||||
ins -= 0xFF;
|
||||
|
||||
*(buf++) = (ins >>= 2);
|
||||
|
||||
if (!--width || !(pixel >>= 1))
|
||||
{
|
||||
*(dst++) = chunk;
|
||||
*(dst++) = chunk;
|
||||
chunk = 0;
|
||||
pixel = 0x8000;
|
||||
}
|
||||
x += info->IncXfx;
|
||||
|
||||
} while (width);
|
||||
}
|
||||
|
||||
inline void dither_D2 ( DECDATA info, void * _dst)
|
||||
{
|
||||
uint16 *dst = _dst;
|
||||
int16 width = info->DthWidth;
|
||||
uint32 x = ( info->IncXfx + 1) >> 1;
|
||||
int16 *buf = info->DthBuf;
|
||||
int16 ins = 0;
|
||||
uint16 pixel = 0x8000;
|
||||
uint16 chunk = 0;
|
||||
|
||||
do
|
||||
{
|
||||
uint8 *rgb = &info->RowBuf[( x >>16) * 3];
|
||||
ins += *buf + (int16)rgb[0] * 5 + (int16)rgb[1] * 9 + (int16)rgb[2] * 2;
|
||||
|
||||
if (ins < 2040)
|
||||
chunk |= pixel;
|
||||
else
|
||||
ins -= 4080;
|
||||
|
||||
*(buf++) = (ins >>= 2);
|
||||
|
||||
if (!--width || !(pixel >>= 1))
|
||||
{
|
||||
*(dst++) = chunk;
|
||||
*(dst++) = chunk;
|
||||
chunk = 0;
|
||||
pixel = 0x8000;
|
||||
}
|
||||
x += info->IncXfx;
|
||||
|
||||
} while ( width);
|
||||
}
|
||||
|
||||
inline void raster_chunks ( uint8 *src, uint16 *dst, uint16 num, uint16 depth)
|
||||
{
|
||||
uint16 mask = 0x8000;
|
||||
uint16 *chunk = dst;
|
||||
uint8 pixel = *src;
|
||||
int16 i = depth;
|
||||
|
||||
do
|
||||
{
|
||||
*( chunk++) = ( pixel & 1 ? mask : 0);
|
||||
pixel >>= 1;
|
||||
} while (--i);
|
||||
|
||||
while (--num)
|
||||
{
|
||||
mask >>= 1;
|
||||
chunk = dst;
|
||||
pixel = *( ++src);
|
||||
i = depth;
|
||||
|
||||
do
|
||||
{
|
||||
if ( pixel & 1) *chunk |= mask;
|
||||
else *chunk &= ~mask;
|
||||
chunk++;
|
||||
pixel >>= 1;
|
||||
} while (--i);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
inline void raster_I4 ( DECDATA info, void * _dst)
|
||||
{
|
||||
uint16 *dst = _dst;
|
||||
int16 width = info->DthWidth;
|
||||
uint32 x = (info->IncXfx +1) >> 1;
|
||||
uint8 buf[16];
|
||||
int16 n = 16;
|
||||
uint8 *tmp = buf;
|
||||
|
||||
do
|
||||
{
|
||||
uint16 idx = info->RowBuf[x >>16];
|
||||
*(tmp++) = *( uint8*)&info->Pixel[idx];
|
||||
|
||||
if (!--width || !--n)
|
||||
{
|
||||
raster_chunk4( buf, dst, tmp - buf);
|
||||
dst += 4;
|
||||
n = 16;
|
||||
tmp = buf;
|
||||
}
|
||||
x += info->IncXfx;
|
||||
|
||||
} while ( width);
|
||||
}
|
||||
|
||||
inline void gscale_I4( DECDATA info, void * _dst)
|
||||
{
|
||||
uint16 *dst = _dst;
|
||||
int16 width = info->DthWidth;
|
||||
uint32 x = (info->IncXfx +1) >> 1;
|
||||
int8 *dth = info->DthBuf;
|
||||
int16 err = 0;
|
||||
uint8 buf[16];
|
||||
int16 n = 16;
|
||||
uint8 *tmp = buf;
|
||||
|
||||
do
|
||||
{
|
||||
*(tmp++) = dither_gray (&info->RowBuf[x >>16], &err, &dth);
|
||||
|
||||
if (!--width || !--n)
|
||||
{
|
||||
raster_chunk4 (buf, dst, tmp - buf);
|
||||
dst += 4;
|
||||
n = 16;
|
||||
tmp = buf;
|
||||
}
|
||||
x += info->IncXfx;
|
||||
|
||||
} while (width);
|
||||
}
|
||||
|
||||
inline void dither_I4 ( DECDATA info, void * _dst)
|
||||
{
|
||||
uint16 *dst = _dst;
|
||||
int16 width = info->DthWidth;
|
||||
uint32 x = (info->IncXfx +1) >> 1;
|
||||
int8 *dth = info->DthBuf;
|
||||
int16 err[3] = { 0, 0, 0 };
|
||||
uint8 buf[16];
|
||||
int16 n = 16;
|
||||
uint8 *tmp = buf;
|
||||
|
||||
do
|
||||
{
|
||||
*(tmp++) = dither_true (&info->RowBuf[(x >>16) *3], err, &dth);
|
||||
|
||||
if (!--width || !--n)
|
||||
{
|
||||
raster_chunk4 (buf, dst, tmp - buf);
|
||||
dst += 4;
|
||||
n = 16;
|
||||
tmp = buf;
|
||||
}
|
||||
x += info->IncXfx;
|
||||
|
||||
} while (width);
|
||||
}
|
||||
|
||||
inline void raster_I8 ( DECDATA info, void * _dst)
|
||||
{
|
||||
uint16 *dst = _dst;
|
||||
int16 width = info->DthWidth;
|
||||
uint32 x = (info->IncXfx +1) >> 1;
|
||||
uint8 buf[16];
|
||||
int16 n = 16;
|
||||
uint8 *tmp = buf;
|
||||
|
||||
do
|
||||
{
|
||||
uint16 idx = info->RowBuf[x >>16];
|
||||
*(tmp++) = *(uint8*)&info->Pixel[idx];
|
||||
|
||||
if (!--width || !--n)
|
||||
{
|
||||
raster_chunk8 (buf, dst, tmp - buf);
|
||||
dst += 8;
|
||||
n = 16;
|
||||
tmp = buf;
|
||||
}
|
||||
x += info->IncXfx;
|
||||
|
||||
} while (width);
|
||||
}
|
||||
|
||||
inline void gscale_I8( DECDATA info, void * _dst)
|
||||
{
|
||||
uint16 *dst = _dst;
|
||||
int16 width = info->DthWidth;
|
||||
uint32 x = (info->IncXfx + 1) >> 1;
|
||||
int8 *dth = info->DthBuf;
|
||||
int16 err = 0;
|
||||
uint8 buf[16];
|
||||
int16 n = 16;
|
||||
uint8 *tmp = buf;
|
||||
|
||||
do
|
||||
{
|
||||
*(tmp++) = dither_gray (&info->RowBuf[x >>16], &err, &dth);
|
||||
|
||||
if (!--width || !--n) {
|
||||
raster_chunk8 (buf, dst, tmp - buf);
|
||||
dst += 8;
|
||||
n = 16;
|
||||
tmp = buf;
|
||||
}
|
||||
x += info->IncXfx;
|
||||
|
||||
} while (width);
|
||||
}
|
||||
|
||||
inline void dither_I8 (DECDATA info, void * _dst)
|
||||
{
|
||||
uint16 *dst = _dst;
|
||||
int16 width = info->DthWidth;
|
||||
uint32 x = (info->IncXfx + 1) >> 1;
|
||||
int8 *dth = info->DthBuf;
|
||||
int16 err[3] = { 0, 0, 0 };
|
||||
uint8 buf[16];
|
||||
int16 n = 16;
|
||||
uint8 *tmp = buf;
|
||||
|
||||
do
|
||||
{
|
||||
*(tmp++) = dither_true (&info->RowBuf[(x >>16) *3], err, &dth);
|
||||
|
||||
if (!--width || !--n)
|
||||
{
|
||||
raster_chunk8 (buf, dst, tmp - buf);
|
||||
dst += 8;
|
||||
n = 16;
|
||||
tmp = buf;
|
||||
}
|
||||
x += info->IncXfx;
|
||||
|
||||
} while ( width);
|
||||
}
|
||||
|
||||
inline void raster_P8 (DECDATA info, void * _dst)
|
||||
{
|
||||
uint8 *dst = _dst;
|
||||
int16 width = info->DthWidth;
|
||||
uint32 x = (info->IncXfx + 1) >> 1;
|
||||
uint32 *map = info->Pixel;
|
||||
uint16 mask = info->PixMask;
|
||||
|
||||
do
|
||||
{
|
||||
*(dst++) = *( uint8*)&map[( int16)info->RowBuf[x >>16] & mask];
|
||||
x += info->IncXfx;
|
||||
} while (--width);
|
||||
}
|
||||
|
||||
inline void gscale_P8( DECDATA info, void * _dst)
|
||||
{
|
||||
uint8 *dst = _dst;
|
||||
int16 width = info->DthWidth;
|
||||
uint32 x = (info->IncXfx + 1) >> 1;
|
||||
int8 *dth = info->DthBuf;
|
||||
int16 err = 0;
|
||||
|
||||
do
|
||||
{
|
||||
*(dst++) = dither_gray (&info->RowBuf[x >>16], &err, &dth);
|
||||
x += info->IncXfx;
|
||||
} while (--width);
|
||||
}
|
||||
|
||||
inline void dither_P8 (DECDATA info, void * _dst)
|
||||
{
|
||||
uint8 *dst = _dst;
|
||||
int16 width = info->DthWidth;
|
||||
uint32 x = (info->IncXfx + 1) >> 1;
|
||||
int8 *dth = info->DthBuf;
|
||||
int16 err[3] = { 0, 0, 0 };
|
||||
|
||||
do
|
||||
{
|
||||
*(dst++) = dither_true (&info->RowBuf[(x >>16) *3], err, &dth);
|
||||
x += info->IncXfx;
|
||||
} while (--width);
|
||||
}
|
||||
|
||||
inline void raster_15 (DECDATA info, void * _dst)
|
||||
{
|
||||
uint16 *dst = _dst;
|
||||
int16 width = info->DthWidth;
|
||||
uint32 x = (info->IncXfx + 1) >> 1;
|
||||
uint32 *map = info->Pixel;
|
||||
uint16 mask = info->PixMask;
|
||||
|
||||
do
|
||||
{
|
||||
*(dst++) = map[(short)info->RowBuf[x >>16] & mask];
|
||||
x += info->IncXfx;
|
||||
} while (--width);
|
||||
}
|
||||
|
||||
inline void gscale_15( DECDATA info, void * _dst)
|
||||
{
|
||||
uint16 * dst = _dst;
|
||||
int16 width = info->DthWidth;
|
||||
uint32 x = (info->IncXfx + 1) >> 1;
|
||||
|
||||
do
|
||||
{
|
||||
uint16 rgb = info->RowBuf[(x >>16)];
|
||||
rgb = ((rgb & 0xF8) <<7) | ((rgb & 0xF8) <<2) | (rgb >>3);
|
||||
*(dst++) = (rgb >> 8) | (rgb << 8);
|
||||
x += info->IncXfx;
|
||||
} while (--width);
|
||||
}
|
||||
|
||||
inline void dither_15 (DECDATA info, void * _dst)
|
||||
{
|
||||
uint16 *dst = _dst;
|
||||
int16 width = info->DthWidth;
|
||||
uint32 x = (info->IncXfx + 1) >> 1;
|
||||
|
||||
do {
|
||||
uint8 * rgb = &info->RowBuf[(x >>16) * 3];
|
||||
*(dst++) = (((uint16)rgb[0] & 0xF8) << 7) | (((uint16)rgb[1] & 0xF8) << 2) | ( rgb[2] >> 3);
|
||||
x += info->IncXfx;
|
||||
} while (--width);
|
||||
}
|
||||
|
||||
inline void raster_15r (DECDATA info, void * _dst)
|
||||
{
|
||||
uint16 *dst = _dst;
|
||||
int16 width = info->DthWidth;
|
||||
uint32 x = (info->IncXfx + 1) >> 1;
|
||||
uint32 *map = info->Pixel;
|
||||
uint16 mask = info->PixMask;
|
||||
|
||||
do
|
||||
{
|
||||
uint16 rgb = map[(short)info->RowBuf[x >>16] & mask];
|
||||
*(dst++) = (rgb >> 8) | (rgb << 8);
|
||||
x += info->IncXfx;
|
||||
} while (--width);
|
||||
}
|
||||
|
||||
inline void gscale_15r( DECDATA info, void * _dst)
|
||||
{
|
||||
uint16 * dst = _dst;
|
||||
int16 width = info->DthWidth;
|
||||
uint32 x = (info->IncXfx + 1) >> 1;
|
||||
|
||||
do
|
||||
{
|
||||
uint16 rgb = info->RowBuf[(x >>16)];
|
||||
rgb = ((rgb & 0xF8) <<7) | ((rgb & 0xF8) <<2) | (rgb >>3);
|
||||
*(dst++) = (rgb >> 8) | (rgb << 8);
|
||||
x += info->IncXfx;
|
||||
} while (--width);
|
||||
}
|
||||
|
||||
inline void dither_15r (DECDATA info, void * _dst)
|
||||
{
|
||||
uint16 *dst = _dst;
|
||||
int16 width = info->DthWidth;
|
||||
uint32 x = (info->IncXfx + 1) >> 1;
|
||||
|
||||
do
|
||||
{
|
||||
uint8 * rgb = &info->RowBuf[(x >>16) * 3];
|
||||
uint16 pix = (((uint16)rgb[0] & 0xF8) << 7) | (((uint16)rgb[1] & 0xF8) << 2) | (rgb[2] >> 3);
|
||||
*(dst++) = (pix >> 8) | (pix << 8);
|
||||
x += info->IncXfx;
|
||||
} while (--width);
|
||||
}
|
||||
|
||||
inline void raster_16 (DECDATA info, void * _dst)
|
||||
{
|
||||
uint16 *dst = _dst;
|
||||
int16 width = info->DthWidth;
|
||||
uint32 x = (info->IncXfx + 1) >> 1;
|
||||
uint32 *map = info->Pixel;
|
||||
uint16 mask = info->PixMask;
|
||||
|
||||
do
|
||||
{
|
||||
*(dst++) = map[(int16)info->RowBuf[x >>16] & mask];
|
||||
x += info->IncXfx;
|
||||
} while (--width);
|
||||
}
|
||||
|
||||
inline void gscale_16( DECDATA info, void * _dst)
|
||||
{
|
||||
register uint16 *dst = _dst;
|
||||
register int16 width = info->DthWidth;
|
||||
register uint32 x = (info->IncXfx + 1) >> 1;
|
||||
|
||||
do
|
||||
{
|
||||
uint16 rgb = info->RowBuf[(x >>16)];
|
||||
*(dst++) = ((rgb & 0xF8) <<8) | ((rgb & 0xFC) <<3) | (rgb >>3);
|
||||
x += info->IncXfx;
|
||||
} while (--width);
|
||||
}
|
||||
|
||||
inline void dither_16 (DECDATA info, void * _dst)
|
||||
{
|
||||
register uint16 *dst = _dst;
|
||||
register int16 width = info->DthWidth;
|
||||
register uint32 x = (info->IncXfx + 1) >> 1;
|
||||
|
||||
do
|
||||
{
|
||||
register uint8 *rgb = &info->RowBuf[(x >> 16) * 3];
|
||||
|
||||
*(dst++) = (((uint16)rgb[0] & 0xF8) << 8) | (((uint16)rgb[1] & 0xFC) << 3) | ( rgb[2] >> 3);
|
||||
x += info->IncXfx;
|
||||
} while (--width);
|
||||
}
|
||||
|
||||
|
||||
inline void raster_16r (DECDATA info, void * _dst)
|
||||
{
|
||||
uint16 *dst = _dst;
|
||||
int16 width = info->DthWidth;
|
||||
uint32 x = (info->IncXfx + 1) >> 1;
|
||||
uint32 *map = info->Pixel;
|
||||
uint16 mask = info->PixMask;
|
||||
|
||||
do
|
||||
{
|
||||
uint16 rgb = map[(int16)info->RowBuf[x >>16] & mask];
|
||||
*(dst++) = (rgb >> 8) | (rgb << 8);
|
||||
x += info->IncXfx;
|
||||
} while (--width);
|
||||
}
|
||||
|
||||
inline void gscale_16r( DECDATA info, void * _dst)
|
||||
{
|
||||
uint16 *dst = _dst;
|
||||
int16 width = info->DthWidth;
|
||||
uint32 x = (info->IncXfx + 1) >> 1;
|
||||
|
||||
do
|
||||
{
|
||||
uint16 rgb = info->RowBuf[(x >>16)];
|
||||
rgb = ((rgb & 0xF8) <<8) | ((rgb & 0xFC) <<3) | (rgb >>3);
|
||||
*(dst++) = (rgb >> 8) | (rgb << 8);
|
||||
x += info->IncXfx;
|
||||
} while (--width);
|
||||
}
|
||||
|
||||
inline void dither_16r (DECDATA info, void * _dst)
|
||||
{
|
||||
uint16 *dst = _dst;
|
||||
int16 width = info->DthWidth;
|
||||
uint32 x = (info->IncXfx + 1) >> 1;
|
||||
|
||||
do
|
||||
{
|
||||
uint8 * rgb = &info->RowBuf[(x >>16) *3];
|
||||
uint16 pix = ((( uint16)rgb[0] & 0xF8) << 8) | ((( uint16)rgb[1] & 0xFC) << 3) | ( rgb[2] >> 3);
|
||||
*(dst++) = (pix >> 8) | (pix << 8);
|
||||
x += info->IncXfx;
|
||||
} while (--width);
|
||||
}
|
||||
|
||||
inline void raster_24 (DECDATA info, void * _dst)
|
||||
{
|
||||
uint8 *dst = _dst;
|
||||
int16 width = info->DthWidth;
|
||||
uint32 x = (info->IncXfx + 1) >> 1;
|
||||
uint32 *map = info->Pixel;
|
||||
uint16 mask = info->PixMask;
|
||||
|
||||
do
|
||||
{
|
||||
uint8 * rgb = (uint8*)&map[( int16)info->RowBuf[x >>16] & mask];
|
||||
*(dst++) = *(++rgb);
|
||||
*(dst++) = *(++rgb);
|
||||
*(dst++) = *(++rgb);
|
||||
x += info->IncXfx;
|
||||
} while (--width);
|
||||
}
|
||||
|
||||
inline void gscale_24( DECDATA info, void * _dst)
|
||||
{
|
||||
uint8 *dst = _dst;
|
||||
int16 width = info->DthWidth;
|
||||
uint32 x = (info->IncXfx + 1) >> 1;
|
||||
|
||||
do
|
||||
{
|
||||
uint8 rgb = info->RowBuf[(x >>16)];
|
||||
*(dst++) = rgb;
|
||||
*(dst++) = rgb;
|
||||
*(dst++) = rgb;
|
||||
x += info->IncXfx;
|
||||
} while (--width);
|
||||
}
|
||||
|
||||
inline void dither_24 (DECDATA info, void * _dst)
|
||||
{
|
||||
uint8 *dst = _dst;
|
||||
int16 width = info->DthWidth;
|
||||
uint32 x = (info->IncXfx + 1) >> 1;
|
||||
|
||||
do
|
||||
{
|
||||
uint8 * rgb = &info->RowBuf[(x >>16) *3];
|
||||
*(dst++) = *(rgb++);
|
||||
*(dst++) = *(rgb++);
|
||||
*(dst++) = *(rgb);
|
||||
x += info->IncXfx;
|
||||
} while (--width);
|
||||
}
|
||||
|
||||
|
||||
inline void raster_24r (DECDATA info, void * _dst)
|
||||
{
|
||||
uint8 *dst = _dst;
|
||||
int16 width = info->DthWidth;
|
||||
uint32 x = (info->IncXfx + 1) >> 1;
|
||||
uint32 *map = info->Pixel;
|
||||
uint16 mask = info->PixMask;
|
||||
|
||||
do
|
||||
{
|
||||
uint8 * rgb = (uint8*)&map[(int16)info->RowBuf[x >>16] & mask];
|
||||
*(dst++) = rgb[3];
|
||||
*(dst++) = rgb[2];
|
||||
*(dst++) = rgb[1];
|
||||
x += info->IncXfx;
|
||||
} while (--width);
|
||||
}
|
||||
|
||||
inline void gscale_24r( DECDATA info, void * _dst)
|
||||
{
|
||||
uint8 *dst = _dst;
|
||||
int16 width = info->DthWidth;
|
||||
uint32 x = (info->IncXfx + 1) >> 1;
|
||||
|
||||
do
|
||||
{
|
||||
uint8 rgb = info->RowBuf[(x >> 16)];
|
||||
*(dst++) = rgb;
|
||||
*(dst++) = rgb;
|
||||
*(dst++) = rgb;
|
||||
x += info->IncXfx;
|
||||
} while (--width);
|
||||
}
|
||||
|
||||
inline void dither_24r( DECDATA info, void * _dst)
|
||||
{
|
||||
uint8 *dst = _dst;
|
||||
int16 width = info->DthWidth;
|
||||
uint32 x = (info->IncXfx + 1) >> 1;
|
||||
|
||||
do
|
||||
{
|
||||
uint8 * rgb = &info->RowBuf[(x >> 16) *3];
|
||||
*(dst++) = rgb[2];
|
||||
*(dst++) = rgb[1];
|
||||
*(dst++) = rgb[0];
|
||||
x += info->IncXfx;
|
||||
} while (--width);
|
||||
}
|
||||
|
||||
inline void raster_32 (DECDATA info, void * _dst)
|
||||
{
|
||||
uint32 * dst = _dst;
|
||||
int16 width = info->DthWidth;
|
||||
uint32 x = (info->IncXfx + 1) >> 1;
|
||||
uint32 *map = info->Pixel;
|
||||
uint16 mask = info->PixMask;
|
||||
|
||||
do
|
||||
{
|
||||
*(dst++) = map[(int16)info->RowBuf[x >> 16] & mask];
|
||||
x += info->IncXfx;
|
||||
} while (--width);
|
||||
}
|
||||
|
||||
inline void gscale_32( DECDATA info, void * _dst)
|
||||
{
|
||||
uint32 *dst = _dst;
|
||||
int16 width = info->DthWidth;
|
||||
uint32 x = (info->IncXfx + 1) >> 1;
|
||||
|
||||
do
|
||||
{
|
||||
uint32 rgb = info->RowBuf[(x >> 16)];
|
||||
*(dst++) = ((( rgb << 8) | rgb) << 8) | rgb;
|
||||
x += info->IncXfx;
|
||||
} while (--width);
|
||||
}
|
||||
|
||||
inline void dither_32 (DECDATA info, void * _dst)
|
||||
{
|
||||
uint32 * dst = _dst;
|
||||
int16 width = info->DthWidth;
|
||||
uint32 x = (info->IncXfx + 1) >> 1;
|
||||
|
||||
do
|
||||
{
|
||||
uint8 * rgb = &info->RowBuf[(x >> 16) *3];
|
||||
*(dst++) = ((((uint32)rgb[0] << 8) | rgb[1]) << 8) | rgb[2];
|
||||
x += info->IncXfx;
|
||||
} while (--width);
|
||||
}
|
||||
|
||||
|
||||
inline void raster_32r( DECDATA info, void * _dst)
|
||||
{
|
||||
uint32 * dst = _dst;
|
||||
int16 width = info->DthWidth;
|
||||
uint32 x = (info->IncXfx + 1) >> 1;
|
||||
uint32 *map = info->Pixel;
|
||||
uint16 mask = info->PixMask;
|
||||
|
||||
do
|
||||
{
|
||||
uint8 * rgb = (uint8*)&map[(int16)info->RowBuf[x >>16] & mask];
|
||||
*(dst++) = (((((int32)rgb[3] << 8) | rgb[2]) << 8) | rgb[1]) << 8;
|
||||
x += info->IncXfx;
|
||||
} while (--width);
|
||||
}
|
||||
|
||||
inline void gscale_32r( DECDATA info, void * _dst)
|
||||
{
|
||||
uint32 *dst = _dst;
|
||||
int16 width = info->DthWidth;
|
||||
uint32 x = (info->IncXfx + 1) >> 1;
|
||||
|
||||
do
|
||||
{
|
||||
uint32 rgb = info->RowBuf[(x >>16)];
|
||||
*(dst++) = (((( rgb << 8) | rgb) << 8) | rgb) << 8;
|
||||
x += info->IncXfx;
|
||||
} while (--width);
|
||||
}
|
||||
|
||||
inline void dither_32r (DECDATA info, void * _dst)
|
||||
{
|
||||
uint32 * dst = _dst;
|
||||
int16 width = info->DthWidth;
|
||||
uint32 x = (info->IncXfx + 1) >> 1;
|
||||
|
||||
do
|
||||
{
|
||||
uint8 * rgb = &info->RowBuf[(x >>16) *3];
|
||||
*(dst++) = (((((uint32)rgb[2] <<8) | rgb[1]) << 8) | rgb[0]) << 8;
|
||||
x += info->IncXfx;
|
||||
} while (--width);
|
||||
}
|
||||
|
||||
inline void raster_32z ( DECDATA info, void * _dst)
|
||||
{
|
||||
uint32 * dst = _dst;
|
||||
int16 width = info->DthWidth;
|
||||
uint32 x = (info->IncXfx +1) >> 1;
|
||||
uint32 * map = info->Pixel;
|
||||
uint16 mask = info->PixMask;
|
||||
do {
|
||||
*(dst++) = map[(int16)info->RowBuf[x >>16] & mask] << 8;
|
||||
x += info->IncXfx;
|
||||
} while (--width);
|
||||
}
|
||||
|
||||
inline void gscale_32z (DECDATA info, void * _dst)
|
||||
{
|
||||
uint32 * dst = _dst;
|
||||
int16 width = info->DthWidth;
|
||||
uint32 x = (info->IncXfx +1) >> 1;
|
||||
do {
|
||||
uint32 rgb = info->RowBuf[(x >>16)];
|
||||
*(dst++) = ((((rgb <<8) | rgb) <<8) | rgb) << 8;
|
||||
x += info->IncXfx;
|
||||
} while (--width);
|
||||
}
|
||||
|
||||
inline void dither_32z (DECDATA info, void * _dst)
|
||||
{
|
||||
uint32 *dst = _dst;
|
||||
int16 width = info->DthWidth;
|
||||
uint32 x = (info->IncXfx +1) >> 1;
|
||||
do {
|
||||
uint8 * rgb = &info->RowBuf[(x >>16) *3];
|
||||
*(dst++) = (((((uint32)rgb[0] <<8) | rgb[1]) <<8) | rgb[2]) << 8;
|
||||
x += info->IncXfx;
|
||||
} while (--width);
|
||||
}
|
||||
63
sources/z-tools/trunk/zcodeclib/src/zvdi/raster.h
Normal file
63
sources/z-tools/trunk/zcodeclib/src/zvdi/raster.h
Normal file
@@ -0,0 +1,63 @@
|
||||
extern void raster_chunks ( uint8 *src, uint16 *dst, uint16 num, uint16 depth);
|
||||
|
||||
#define raster_chunk4(s,d,n) raster_chunks ( s, d, n, 4)
|
||||
#define raster_chunk8(s,d,n) raster_chunks ( s, d, n, 8)
|
||||
|
||||
extern void raster_mono ( DECDATA info, void * _dst);
|
||||
extern void raster_D1 ( DECDATA info, void * _dst);
|
||||
extern void dither_D1 ( DECDATA info, void * _dst);
|
||||
extern void gscale_D1 ( DECDATA info, void * _dst);
|
||||
|
||||
extern void raster_D2 ( DECDATA info, void * _dst);
|
||||
|
||||
extern void dither_D2 ( DECDATA info, void * _dst);
|
||||
extern void gscale_D2 ( DECDATA info, void * _dst);
|
||||
|
||||
extern void raster_I4 ( DECDATA info, void * _dst);
|
||||
extern void dither_I4 ( DECDATA info, void * _dst);
|
||||
extern void gscale_I4 ( DECDATA info, void * _dst);
|
||||
|
||||
extern void raster_I8 ( DECDATA info, void * _dst);
|
||||
extern void dither_I8 ( DECDATA info, void * _dst);
|
||||
extern void gscale_I8 ( DECDATA info, void * _dst);
|
||||
|
||||
extern void raster_P8 ( DECDATA info, void * _dst);
|
||||
extern void dither_P8 ( DECDATA info, void * _dst);
|
||||
extern void gscale_P8 ( DECDATA info, void * _dst);
|
||||
|
||||
extern void raster_15 ( DECDATA info, void * _dst);
|
||||
extern void dither_15 ( DECDATA info, void * _dst);
|
||||
extern void gscale_15 ( DECDATA info, void * _dst);
|
||||
|
||||
extern void raster_15r ( DECDATA info, void * _dst);
|
||||
extern void dither_15r ( DECDATA info, void * _dst);
|
||||
extern void gscale_15r ( DECDATA info, void * _dst);
|
||||
|
||||
extern void raster_16 ( DECDATA info, void * _dst);
|
||||
extern void dither_16 ( DECDATA info, void * _dst);
|
||||
extern void gscale_16 ( DECDATA info, void * _dst);
|
||||
|
||||
extern void raster_16r ( DECDATA info, void * _dst);
|
||||
extern void dither_16r ( DECDATA info, void * _dst);
|
||||
extern void gscale_16r ( DECDATA info, void * _dst);
|
||||
|
||||
extern void raster_24 ( DECDATA info, void * _dst);
|
||||
extern void dither_24 ( DECDATA info, void * _dst);
|
||||
extern void gscale_24 ( DECDATA info, void * _dst);
|
||||
|
||||
extern void raster_24r ( DECDATA info, void * _dst);
|
||||
extern void dither_24r ( DECDATA info, void * _dst);
|
||||
extern void gscale_24r ( DECDATA info, void * _dst);
|
||||
|
||||
extern void raster_32 ( DECDATA info, void * _dst);
|
||||
extern void dither_32 ( DECDATA info, void * _dst);
|
||||
extern void gscale_32 ( DECDATA info, void * _dst);
|
||||
|
||||
extern void raster_32r ( DECDATA info, void * _dst);
|
||||
extern void dither_32r ( DECDATA info, void * _dst);
|
||||
extern void gscale_32r ( DECDATA info, void * _dst);
|
||||
|
||||
extern void raster_32z ( DECDATA info, void * _dst);
|
||||
extern void dither_32z ( DECDATA info, void * _dst);
|
||||
extern void gscale_32z ( DECDATA info, void * _dst);
|
||||
|
||||
221
sources/z-tools/trunk/zcodeclib/src/zvdi/vdi.c
Normal file
221
sources/z-tools/trunk/zcodeclib/src/zvdi/vdi.c
Normal file
@@ -0,0 +1,221 @@
|
||||
#ifdef __PUREC__
|
||||
#include "..\general.h"
|
||||
#include "..\resize.h"
|
||||
#include "..\load_img.h"
|
||||
#else
|
||||
#include "../general.h"
|
||||
#include "../load_img.h"
|
||||
#include "../resize.h"
|
||||
#endif
|
||||
#include "raster.h"
|
||||
#include "raresize.h"
|
||||
#include "color.h"
|
||||
#include "p2c.h"
|
||||
|
||||
int16 pixel_val[256];
|
||||
uint32 cube216[216];
|
||||
uint32 graymap[32];
|
||||
int16 planar = 0;
|
||||
int16 vdi_handle, nplanes, vdi_work_in[10], vdi_work_out[57];
|
||||
|
||||
|
||||
/* prototype */
|
||||
int16 vdi_init ( void);
|
||||
|
||||
|
||||
int16 vdi_init( void)
|
||||
{
|
||||
int16 out[273] = { -1, };
|
||||
int16 dum, depth, aes_handle;
|
||||
boolean reverse, z_trail;
|
||||
int32 cookie_dum;
|
||||
|
||||
if( !ldg_cookie( 0x45644449L, (int32*)&cookie_dum))
|
||||
return( 0);
|
||||
|
||||
/* open a VDI workstation */
|
||||
aes_handle = graf_handle( &dum, &dum, &dum, &dum);
|
||||
vq_extnd( aes_handle, 1, vdi_work_out);
|
||||
nplanes = vdi_work_out[ 4];
|
||||
vdi_work_in[0] = Getrez() + 2;
|
||||
vdi_handle = aes_handle;
|
||||
v_opnvwk( vdi_work_in, &vdi_handle, vdi_work_out);
|
||||
|
||||
/* Get the screen's informations */
|
||||
vq_scrninfo ( vdi_handle, out);
|
||||
|
||||
if ( nplanes <= 8)
|
||||
{
|
||||
save_colors();
|
||||
memcpy ( pixel_val, out + 16, 512);
|
||||
}
|
||||
|
||||
depth = (( uint16)out[4] == 0x8000u ? 15 : out[2]); /* bits per pixel used */
|
||||
reverse = (out[16] < out[48]); /* intel crap... */
|
||||
z_trail = (out[48] > 0); /* bits are shifted to the right side */
|
||||
|
||||
if ( depth == 1)
|
||||
{ /* monochrome */
|
||||
cnvpal_color = cnvpal_1_2;
|
||||
raster_cmap = raster_D1;
|
||||
raster_true = dither_D1;
|
||||
raster_gray = gscale_D1;
|
||||
resize = resize_mono;
|
||||
}
|
||||
else if ( out[0] == 0) /* Planar */
|
||||
{
|
||||
planar = 1;
|
||||
|
||||
switch ( depth)
|
||||
{
|
||||
case 2:
|
||||
cnvpal_color = cnvpal_1_2;
|
||||
raster_cmap = raster_D2;
|
||||
raster_true = dither_D2;
|
||||
raster_gray = gscale_D2;
|
||||
planar_to_chunky = planar2_to_chunky8;
|
||||
break;
|
||||
case 4:
|
||||
cnvpal_color = cnvpal_4_8;
|
||||
raster_cmap = raster_I4;
|
||||
raster_true = dither_I4;
|
||||
raster_gray = gscale_I4;
|
||||
resize = resize_I4;
|
||||
planar_to_chunky = planar4_to_chunky8;
|
||||
break;
|
||||
case 8:
|
||||
cnvpal_color = cnvpal_4_8;
|
||||
raster_cmap = raster_I8;
|
||||
raster_true = dither_I8;
|
||||
raster_gray = gscale_I8;
|
||||
resize = resize_I8;
|
||||
planar_to_chunky = planar8_to_chunky8;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if ( out[0] == 2) /* chunky */
|
||||
switch ( depth)
|
||||
{
|
||||
case 8:
|
||||
cnvpal_color = cnvpal_4_8;
|
||||
raster_cmap = raster_P8;
|
||||
raster_true = dither_P8;
|
||||
raster_gray = gscale_P8;
|
||||
resize = resize_P8;
|
||||
break;
|
||||
|
||||
case 15:
|
||||
if (!(out[14] & 0x02))
|
||||
{
|
||||
cnvpal_color = cnvpal_15;
|
||||
|
||||
if (reverse)
|
||||
{
|
||||
raster_cmap = raster_15r;
|
||||
raster_gray = gscale_15r;
|
||||
raster_true = dither_15r;
|
||||
}
|
||||
else
|
||||
{
|
||||
raster_cmap = raster_15;
|
||||
raster_gray = gscale_15;
|
||||
raster_true = dither_15;
|
||||
}
|
||||
|
||||
resize = resize_16;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case 16:
|
||||
cnvpal_color = cnvpal_high;
|
||||
|
||||
if (reverse)
|
||||
{
|
||||
raster_cmap = raster_16r;
|
||||
raster_gray = gscale_16r;
|
||||
raster_true = dither_16r;
|
||||
}
|
||||
else
|
||||
{
|
||||
raster_cmap = raster_16;
|
||||
raster_gray = gscale_16;
|
||||
raster_true = dither_16;
|
||||
}
|
||||
|
||||
resize = resize_16;
|
||||
|
||||
break;
|
||||
|
||||
case 24:
|
||||
cnvpal_color = cnvpal_true;
|
||||
|
||||
if (reverse)
|
||||
{
|
||||
raster_cmap = raster_24r;
|
||||
raster_gray = gscale_24r;
|
||||
raster_true = dither_24r;
|
||||
}
|
||||
else
|
||||
{
|
||||
raster_cmap = raster_24;
|
||||
raster_gray = gscale_24;
|
||||
raster_true = dither_24;
|
||||
}
|
||||
|
||||
resize = resize_24;
|
||||
|
||||
break;
|
||||
|
||||
case 32:
|
||||
cnvpal_color = cnvpal_true;
|
||||
|
||||
if (reverse)
|
||||
{
|
||||
raster_cmap = raster_32r;
|
||||
raster_gray = gscale_32r;
|
||||
raster_true = dither_32r;
|
||||
}
|
||||
else if( z_trail)
|
||||
{
|
||||
raster_cmap = raster_32z;
|
||||
raster_gray = gscale_32z;
|
||||
raster_true = dither_32z;
|
||||
}
|
||||
else
|
||||
{
|
||||
raster_cmap = raster_32;
|
||||
raster_gray = gscale_32;
|
||||
raster_true = dither_32;
|
||||
}
|
||||
|
||||
resize = resize_32;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
if (depth == 4 || depth == 8)
|
||||
{
|
||||
uint32 * dst;
|
||||
uint32 r, g, b;
|
||||
dst = cube216;
|
||||
|
||||
for (r = 0x000000uL; r <= 0xFF0000uL; r += 0x330000uL)
|
||||
{
|
||||
for (g = 0x000000uL; g <= 0x00FF00uL; g += 0x003300uL)
|
||||
{
|
||||
for (b = 0x000000uL; b <= 0x0000FFuL; b += 0x000033uL)
|
||||
{
|
||||
*(dst++) = color_lookup ( r | g | b, pixel_val);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dst = graymap;
|
||||
|
||||
for ( g = 0x000000uL; g <= 0xF8F8F8uL; g += 0x080808uL)
|
||||
*( dst++) = color_lookup ( g | (( g >> 5) & 0x030303uL), pixel_val);
|
||||
}
|
||||
|
||||
return( 1);
|
||||
}
|
||||
7
sources/z-tools/trunk/zcodeclib/src/zvdi/vdi.h
Normal file
7
sources/z-tools/trunk/zcodeclib/src/zvdi/vdi.h
Normal file
@@ -0,0 +1,7 @@
|
||||
extern int16 pixel_val[256];
|
||||
extern uint32 cube216[216];
|
||||
extern uint32 graymap[32];
|
||||
|
||||
extern int16 vdi_init( void);
|
||||
extern int16 planar, vdi_handle, nplanes, vdi_work_in[10], vdi_work_out[57];
|
||||
|
||||
BIN
sources/z-tools/trunk/zcodeclib/zcodeclib.hyp
Normal file
BIN
sources/z-tools/trunk/zcodeclib/zcodeclib.hyp
Normal file
Binary file not shown.
355
sources/z-tools/trunk/zcodeclib/zcodeclib.stg
Normal file
355
sources/z-tools/trunk/zcodeclib/zcodeclib.stg
Normal file
@@ -0,0 +1,355 @@
|
||||
@database "zcodeclib Dev. Guide"
|
||||
@subject "Documentation"
|
||||
@author "Zorro"
|
||||
@$VER: ZCODEC.HYP (@:"__DATE__")
|
||||
@options +Z
|
||||
@options -S
|
||||
|
||||
@default Index
|
||||
|
||||
@node Index "zcodeclib dev."
|
||||
zcodeclib dev.
|
||||
@line 1 70 0 0 1
|
||||
|
||||
|
||||
1. Introduction
|
||||
2. Functions
|
||||
3. Global variables
|
||||
4. The IMAGE structure.
|
||||
5. Do you use MEM.LDG in your application?
|
||||
|
||||
|
||||
@endnode
|
||||
|
||||
|
||||
@node "Introduction"
|
||||
1. Introduction
|
||||
@line 1 70 0 0 1
|
||||
|
||||
Make a basic GEM application is a very easy task but problems
|
||||
become when we have to draw something on the screen.
|
||||
|
||||
Indeed, on Atari and others TOS computers, there are many
|
||||
different screens' formats and, of course, we can't deal with
|
||||
it in the same manner.
|
||||
|
||||
The problem is worst when we have to load and to draw a picture
|
||||
from, for example, a JPG file. We have to make ourselves loading
|
||||
routines, etc... A real nightmare!
|
||||
|
||||
The goal of this library is to offer easy and fast functions for
|
||||
load images from file and for, especially, deal with the screen.
|
||||
It provide also useful functions like MFDB zooming and others.
|
||||
|
||||
This library load and use the zview's codecs, so it's fast and
|
||||
stable.
|
||||
|
||||
@{B}For use this library, you need:@{0}
|
||||
|
||||
- A VDI with a valid EDDI (like NovaVDI, NVDI > 2.5, fVDI, etc..).
|
||||
- The zview's codec correctly installed with mem.ldg (provided in
|
||||
the zview archive).
|
||||
- the LDG library ( http://ldg.org.free.fr)
|
||||
- A recent GEMLIB.
|
||||
|
||||
|
||||
(Index)
|
||||
|
||||
@endnode
|
||||
|
||||
@node "Functions"
|
||||
2. Functions
|
||||
@line 1 70 0 0 1
|
||||
|
||||
|
||||
1. codecs_init()
|
||||
2. codecs_quit()
|
||||
3. load_img()
|
||||
4. delete_img()
|
||||
5. pic_resize()
|
||||
6. delete_mfdb()
|
||||
|
||||
|
||||
(Index)
|
||||
|
||||
@endnode
|
||||
|
||||
|
||||
@node "codecs_init()"
|
||||
codecs_init()
|
||||
@line 1 70 0 0 1
|
||||
|
||||
@{B}NAME@{0}
|
||||
codec_init - initialise and load the wanted codecs.
|
||||
|
||||
@{B}PROTOTYPAGE@{0}
|
||||
int16 codecs_init( char *codec_name);
|
||||
|
||||
|
||||
@{B}PARAMETERS@{0}
|
||||
codec_name: the name of the codec to load.
|
||||
|
||||
return: 0 if an error occurs else 1.
|
||||
|
||||
|
||||
@{B}DESCRIPTION@{0}
|
||||
It's the first function to call.
|
||||
|
||||
The function's job is to initialize the VDI's informations,
|
||||
load MEM.LDG ( for shareable allocation) and load the wanted
|
||||
codecs.
|
||||
|
||||
For example:
|
||||
|
||||
codecs_init( "jpg.ldg");
|
||||
|
||||
If you need others codecs, you can to call this function any
|
||||
numbers of times like:
|
||||
|
||||
codecs_init( "jpg.ldg");
|
||||
codecs_init( "png.ldg");
|
||||
....
|
||||
|
||||
Cool feature, you can load the complete codec's pack with:
|
||||
|
||||
codec_init( "all");
|
||||
|
||||
|
||||
@{B}IMPORTANT@{0}
|
||||
Be careful, you can't load two times the same codec so, don't
|
||||
call again this function after a codec_init( "all").
|
||||
|
||||
|
||||
(Index)
|
||||
|
||||
@endnode
|
||||
|
||||
@node "codecs_quit()"
|
||||
codecs_quit()
|
||||
@line 1 70 0 0 1
|
||||
|
||||
@{B}NAME@{0}
|
||||
codecs_quit - unload the codecs and MEM.LDG.
|
||||
|
||||
@{B}PROTOTYPAGE@{0}
|
||||
void codecs_quit( void);
|
||||
|
||||
|
||||
@{B}DESCRIPTION@{0}
|
||||
You must call this function at the end of your code or when we
|
||||
don't use anymore the functions form this library.
|
||||
|
||||
It unloads MEM.LDG and the codecs previously loaded.
|
||||
|
||||
|
||||
(Index)
|
||||
|
||||
@endnode
|
||||
|
||||
@node "load_img()"
|
||||
load_img()
|
||||
@line 1 70 0 0 1
|
||||
|
||||
@{B}NAME@{0}l
|
||||
load_img() - load, convert and zoom a image.
|
||||
|
||||
@{B}PROTOTYPAGE@{0}
|
||||
IMAGE *load_img( const char *file, int16 w, int16 h, int16 keep_ratio);
|
||||
|
||||
|
||||
@{B}PARAMETERS@{0}
|
||||
file: the file to load.
|
||||
|
||||
w: the wanted image's width.
|
||||
-1 for to keep the image's width.
|
||||
|
||||
h: the wanted image's height.
|
||||
-1 for to keep the image's height.
|
||||
|
||||
keep_ratio: in the case where you set the wanted image's size
|
||||
with the w and h variables, if 'keep_ratio' if TRUE,
|
||||
the image is resized to fit in w and h for maintain
|
||||
the aspect ratio else the image will be exactly at
|
||||
the wanted size.
|
||||
|
||||
|
||||
return: NULL if an error occurs else a valid IMAGE structure.
|
||||
|
||||
|
||||
@{B}DESCRIPTION@{0}
|
||||
The most important function of this library; it loads, converts
|
||||
to screen format and eventually, zooms a picture. All in one
|
||||
function!
|
||||
|
||||
|
||||
@{B}IMPORTANT@{0}
|
||||
Don't allocate the IMG structure yourself, the function make it
|
||||
for you (see example.c).
|
||||
|
||||
|
||||
(Index)
|
||||
|
||||
@endnode
|
||||
|
||||
|
||||
|
||||
@endnode
|
||||
|
||||
@node "delete_img()"
|
||||
delete_img()
|
||||
@line 1 70 0 0 1
|
||||
|
||||
@{B}NAME@{0}
|
||||
delete_img - free a IMAGE structure.
|
||||
|
||||
@{B}PROTOTYPAGE@{0}
|
||||
void delete_img( IMAGE *img);
|
||||
|
||||
|
||||
@{B}DESCRIPTION@{0}
|
||||
This function frees all the memories previously allocated for
|
||||
the "img" structure and also "img" itself.
|
||||
|
||||
(Index)
|
||||
|
||||
@endnode
|
||||
|
||||
|
||||
@node "pic_resize()"
|
||||
pic_resize()
|
||||
@line 1 70 0 0 1
|
||||
|
||||
@{B}NAME@{0}l
|
||||
pic_resize() - resize a MFDB.
|
||||
|
||||
@{B}PROTOTYPAGE@{0}
|
||||
MFDB *pic_resize( MFDB *in, int16 w, int16 h, int16 keep_ratio);
|
||||
|
||||
|
||||
@{B}PARAMETERS@{0}
|
||||
in: the input MFDB address.
|
||||
|
||||
w: the wanted MFDB's width.
|
||||
|
||||
h: the wanted MFDB's height.
|
||||
|
||||
keep_ratio: if 'keep_ratio' if TRUE, the MFDB is resized for to
|
||||
fit in 'w' and 'h' for maintain the aspect ratio
|
||||
else the MFDB will be exactly at the 'w' and 'h' size.
|
||||
|
||||
return: NULL if an error occurs else a valid MFDB address.
|
||||
|
||||
|
||||
@{B}DESCRIPTION@{0}
|
||||
Return a MFDB resized with the data of 'in'.
|
||||
|
||||
|
||||
@{B}IMPORTANT@{0}
|
||||
1) Don't allocate the "out" MFDB yourself, the function make it
|
||||
for you (see example.c).
|
||||
2) You can't free the MFDB youself, use delete_mfdb() for do that.
|
||||
|
||||
|
||||
(Index)
|
||||
|
||||
@endnode
|
||||
|
||||
|
||||
|
||||
@node "delete_mfdb()"
|
||||
delete_mfdb()
|
||||
@line 1 70 0 0 1
|
||||
|
||||
@{B}NAME@{0}l
|
||||
delete_mfdb() - delete one or more MFDB structure(s).
|
||||
|
||||
@{B}PROTOTYPAGE@{0}
|
||||
void delete_mfdb( MFDB *bm, int16 nbr);
|
||||
|
||||
|
||||
@{B}PARAMETERS@{0}
|
||||
bm: the MFDB to free.
|
||||
|
||||
nbr: the number of MFDB in 'bm'.
|
||||
|
||||
return: nothing.
|
||||
|
||||
|
||||
@{B}DESCRIPTION@{0}
|
||||
Free one or more MFDB created with pic_resize().
|
||||
|
||||
|
||||
(Index)
|
||||
|
||||
@endnode
|
||||
|
||||
|
||||
@node "Global variables"
|
||||
Global variables
|
||||
@line 1 70 0 0 1
|
||||
|
||||
|
||||
All this global variable are in in16 format( short).
|
||||
|
||||
planar: The screen format, 1 if planar else 0.
|
||||
|
||||
nplanes: the screen planes' number.
|
||||
|
||||
vdi_work_in[10], vdi_work_out[57]: useful information about
|
||||
the VDI.
|
||||
|
||||
vdi_handle: a "ready to use" VDI handle.
|
||||
|
||||
|
||||
(Index)
|
||||
|
||||
@endnode
|
||||
|
||||
|
||||
@node "IMAGE"
|
||||
IMAGE
|
||||
@line 1 70 0 0 1
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int16 page;
|
||||
uint16 *delay;
|
||||
MFDB *image;
|
||||
} IMAGE;
|
||||
|
||||
|
||||
delay: exists only if the image is a animated one ( for example:
|
||||
animated GIF, FLI, etc..).
|
||||
|
||||
page: is the number of image returned (For animated picture or
|
||||
multi-pages documents like FAX).
|
||||
|
||||
image: is one of many MFDB structure(s) ready to be transferred to
|
||||
the screen.
|
||||
|
||||
|
||||
@endnode
|
||||
|
||||
|
||||
@node "Do you use MEM.LDG in your application?"
|
||||
Do you use MEM.LDG in your application?
|
||||
@line 1 70 0 0 1
|
||||
|
||||
|
||||
Libzcodec loads already the MEM.LDG so you can't do it again in your
|
||||
code!
|
||||
|
||||
For this prupose, in the header's file, we can find
|
||||
'shared_malloc( a)' and 'shared_free( a)'.
|
||||
|
||||
This functions are only ldg_malloc() and ldg_free() binded; you
|
||||
can use it without any problem and if far better that Mintlib malloc's
|
||||
function.
|
||||
|
||||
If you need ldg_realloc or ldg_calloc, you need to make a
|
||||
ldg_find( "ldg_calloc", ldg_mem) youself. ( ldg_mem is a global
|
||||
variable used for load MEM.LDG).
|
||||
|
||||
|
||||
@endnode
|
||||
Reference in New Issue
Block a user