├── .github └── workflows │ └── c-cpp.yml ├── AUTHORS ├── COPYING ├── ChangeLog ├── INSTALL ├── Makefile.am ├── NEWS ├── README ├── configure.ac ├── debian ├── changelog ├── compat ├── control ├── copyright ├── docs ├── libhqx-bin.dirs ├── libhqx-bin.install ├── libhqx-dev.dirs ├── libhqx-dev.install ├── libhqx1.dirs ├── libhqx1.install └── rules └── src ├── Makefile.am ├── common.h ├── hq2x.c ├── hq3x.c ├── hq4x.c ├── hqx.c ├── hqx.h └── init.c /.github/workflows/c-cpp.yml: -------------------------------------------------------------------------------- 1 | name: C/C++ CI 2 | 3 | on: 4 | push: {} 5 | pull_request: {} 6 | 7 | jobs: 8 | build: 9 | 10 | runs-on: ubuntu-latest 11 | 12 | env: 13 | DH_VERBOSE: 1 14 | 15 | steps: 16 | - uses: actions/checkout@v4 17 | - name: deps 18 | run: | 19 | sudo apt-get install -y autotools-dev build-essential debhelper dpkg-dev devscripts libdevil-dev 20 | - name: package 21 | run: dpkg-buildpackage -nc -uc -b -rfakeroot 22 | -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- 1 | Maxim Stepin - Creator of hqx filter 2 | 3 | Cameron Zemek - Package maintainer. Added 24bit color support. 4 | 5 | Francois Gannaz - Added transparency support. 6 | -------------------------------------------------------------------------------- /COPYING: -------------------------------------------------------------------------------- 1 | GNU LESSER GENERAL PUBLIC LICENSE 2 | Version 2.1, February 1999 3 | 4 | Copyright (C) 1991, 1999 Free Software Foundation, Inc. 5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 6 | Everyone is permitted to copy and distribute verbatim copies 7 | of this license document, but changing it is not allowed. 8 | 9 | [This is the first released version of the Lesser GPL. It also counts 10 | as the successor of the GNU Library Public License, version 2, hence 11 | the version number 2.1.] 12 | 13 | Preamble 14 | 15 | The licenses for most software are designed to take away your 16 | freedom to share and change it. By contrast, the GNU General Public 17 | Licenses are intended to guarantee your freedom to share and change 18 | free software--to make sure the software is free for all its users. 19 | 20 | This license, the Lesser General Public License, applies to some 21 | specially designated software packages--typically libraries--of the 22 | Free Software Foundation and other authors who decide to use it. You 23 | can use it too, but we suggest you first think carefully about whether 24 | this license or the ordinary General Public License is the better 25 | strategy to use in any particular case, based on the explanations below. 26 | 27 | When we speak of free software, we are referring to freedom of use, 28 | not price. Our General Public Licenses are designed to make sure that 29 | you have the freedom to distribute copies of free software (and charge 30 | for this service if you wish); that you receive source code or can get 31 | it if you want it; that you can change the software and use pieces of 32 | it in new free programs; and that you are informed that you can do 33 | these things. 34 | 35 | To protect your rights, we need to make restrictions that forbid 36 | distributors to deny you these rights or to ask you to surrender these 37 | rights. These restrictions translate to certain responsibilities for 38 | you if you distribute copies of the library or if you modify it. 39 | 40 | For example, if you distribute copies of the library, whether gratis 41 | or for a fee, you must give the recipients all the rights that we gave 42 | you. You must make sure that they, too, receive or can get the source 43 | code. If you link other code with the library, you must provide 44 | complete object files to the recipients, so that they can relink them 45 | with the library after making changes to the library and recompiling 46 | it. And you must show them these terms so they know their rights. 47 | 48 | We protect your rights with a two-step method: (1) we copyright the 49 | library, and (2) we offer you this license, which gives you legal 50 | permission to copy, distribute and/or modify the library. 51 | 52 | To protect each distributor, we want to make it very clear that 53 | there is no warranty for the free library. Also, if the library is 54 | modified by someone else and passed on, the recipients should know 55 | that what they have is not the original version, so that the original 56 | author's reputation will not be affected by problems that might be 57 | introduced by others. 58 | 59 | Finally, software patents pose a constant threat to the existence of 60 | any free program. We wish to make sure that a company cannot 61 | effectively restrict the users of a free program by obtaining a 62 | restrictive license from a patent holder. Therefore, we insist that 63 | any patent license obtained for a version of the library must be 64 | consistent with the full freedom of use specified in this license. 65 | 66 | Most GNU software, including some libraries, is covered by the 67 | ordinary GNU General Public License. This license, the GNU Lesser 68 | General Public License, applies to certain designated libraries, and 69 | is quite different from the ordinary General Public License. We use 70 | this license for certain libraries in order to permit linking those 71 | libraries into non-free programs. 72 | 73 | When a program is linked with a library, whether statically or using 74 | a shared library, the combination of the two is legally speaking a 75 | combined work, a derivative of the original library. The ordinary 76 | General Public License therefore permits such linking only if the 77 | entire combination fits its criteria of freedom. The Lesser General 78 | Public License permits more lax criteria for linking other code with 79 | the library. 80 | 81 | We call this license the "Lesser" General Public License because it 82 | does Less to protect the user's freedom than the ordinary General 83 | Public License. It also provides other free software developers Less 84 | of an advantage over competing non-free programs. These disadvantages 85 | are the reason we use the ordinary General Public License for many 86 | libraries. However, the Lesser license provides advantages in certain 87 | special circumstances. 88 | 89 | For example, on rare occasions, there may be a special need to 90 | encourage the widest possible use of a certain library, so that it becomes 91 | a de-facto standard. To achieve this, non-free programs must be 92 | allowed to use the library. A more frequent case is that a free 93 | library does the same job as widely used non-free libraries. In this 94 | case, there is little to gain by limiting the free library to free 95 | software only, so we use the Lesser General Public License. 96 | 97 | In other cases, permission to use a particular library in non-free 98 | programs enables a greater number of people to use a large body of 99 | free software. For example, permission to use the GNU C Library in 100 | non-free programs enables many more people to use the whole GNU 101 | operating system, as well as its variant, the GNU/Linux operating 102 | system. 103 | 104 | Although the Lesser General Public License is Less protective of the 105 | users' freedom, it does ensure that the user of a program that is 106 | linked with the Library has the freedom and the wherewithal to run 107 | that program using a modified version of the Library. 108 | 109 | The precise terms and conditions for copying, distribution and 110 | modification follow. Pay close attention to the difference between a 111 | "work based on the library" and a "work that uses the library". The 112 | former contains code derived from the library, whereas the latter must 113 | be combined with the library in order to run. 114 | 115 | GNU LESSER GENERAL PUBLIC LICENSE 116 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 117 | 118 | 0. This License Agreement applies to any software library or other 119 | program which contains a notice placed by the copyright holder or 120 | other authorized party saying it may be distributed under the terms of 121 | this Lesser General Public License (also called "this License"). 122 | Each licensee is addressed as "you". 123 | 124 | A "library" means a collection of software functions and/or data 125 | prepared so as to be conveniently linked with application programs 126 | (which use some of those functions and data) to form executables. 127 | 128 | The "Library", below, refers to any such software library or work 129 | which has been distributed under these terms. A "work based on the 130 | Library" means either the Library or any derivative work under 131 | copyright law: that is to say, a work containing the Library or a 132 | portion of it, either verbatim or with modifications and/or translated 133 | straightforwardly into another language. (Hereinafter, translation is 134 | included without limitation in the term "modification".) 135 | 136 | "Source code" for a work means the preferred form of the work for 137 | making modifications to it. For a library, complete source code means 138 | all the source code for all modules it contains, plus any associated 139 | interface definition files, plus the scripts used to control compilation 140 | and installation of the library. 141 | 142 | Activities other than copying, distribution and modification are not 143 | covered by this License; they are outside its scope. The act of 144 | running a program using the Library is not restricted, and output from 145 | such a program is covered only if its contents constitute a work based 146 | on the Library (independent of the use of the Library in a tool for 147 | writing it). Whether that is true depends on what the Library does 148 | and what the program that uses the Library does. 149 | 150 | 1. You may copy and distribute verbatim copies of the Library's 151 | complete source code as you receive it, in any medium, provided that 152 | you conspicuously and appropriately publish on each copy an 153 | appropriate copyright notice and disclaimer of warranty; keep intact 154 | all the notices that refer to this License and to the absence of any 155 | warranty; and distribute a copy of this License along with the 156 | Library. 157 | 158 | You may charge a fee for the physical act of transferring a copy, 159 | and you may at your option offer warranty protection in exchange for a 160 | fee. 161 | 162 | 2. You may modify your copy or copies of the Library or any portion 163 | of it, thus forming a work based on the Library, and copy and 164 | distribute such modifications or work under the terms of Section 1 165 | above, provided that you also meet all of these conditions: 166 | 167 | a) The modified work must itself be a software library. 168 | 169 | b) You must cause the files modified to carry prominent notices 170 | stating that you changed the files and the date of any change. 171 | 172 | c) You must cause the whole of the work to be licensed at no 173 | charge to all third parties under the terms of this License. 174 | 175 | d) If a facility in the modified Library refers to a function or a 176 | table of data to be supplied by an application program that uses 177 | the facility, other than as an argument passed when the facility 178 | is invoked, then you must make a good faith effort to ensure that, 179 | in the event an application does not supply such function or 180 | table, the facility still operates, and performs whatever part of 181 | its purpose remains meaningful. 182 | 183 | (For example, a function in a library to compute square roots has 184 | a purpose that is entirely well-defined independent of the 185 | application. Therefore, Subsection 2d requires that any 186 | application-supplied function or table used by this function must 187 | be optional: if the application does not supply it, the square 188 | root function must still compute square roots.) 189 | 190 | These requirements apply to the modified work as a whole. If 191 | identifiable sections of that work are not derived from the Library, 192 | and can be reasonably considered independent and separate works in 193 | themselves, then this License, and its terms, do not apply to those 194 | sections when you distribute them as separate works. But when you 195 | distribute the same sections as part of a whole which is a work based 196 | on the Library, the distribution of the whole must be on the terms of 197 | this License, whose permissions for other licensees extend to the 198 | entire whole, and thus to each and every part regardless of who wrote 199 | it. 200 | 201 | Thus, it is not the intent of this section to claim rights or contest 202 | your rights to work written entirely by you; rather, the intent is to 203 | exercise the right to control the distribution of derivative or 204 | collective works based on the Library. 205 | 206 | In addition, mere aggregation of another work not based on the Library 207 | with the Library (or with a work based on the Library) on a volume of 208 | a storage or distribution medium does not bring the other work under 209 | the scope of this License. 210 | 211 | 3. You may opt to apply the terms of the ordinary GNU General Public 212 | License instead of this License to a given copy of the Library. To do 213 | this, you must alter all the notices that refer to this License, so 214 | that they refer to the ordinary GNU General Public License, version 2, 215 | instead of to this License. (If a newer version than version 2 of the 216 | ordinary GNU General Public License has appeared, then you can specify 217 | that version instead if you wish.) Do not make any other change in 218 | these notices. 219 | 220 | Once this change is made in a given copy, it is irreversible for 221 | that copy, so the ordinary GNU General Public License applies to all 222 | subsequent copies and derivative works made from that copy. 223 | 224 | This option is useful when you wish to copy part of the code of 225 | the Library into a program that is not a library. 226 | 227 | 4. You may copy and distribute the Library (or a portion or 228 | derivative of it, under Section 2) in object code or executable form 229 | under the terms of Sections 1 and 2 above provided that you accompany 230 | it with the complete corresponding machine-readable source code, which 231 | must be distributed under the terms of Sections 1 and 2 above on a 232 | medium customarily used for software interchange. 233 | 234 | If distribution of object code is made by offering access to copy 235 | from a designated place, then offering equivalent access to copy the 236 | source code from the same place satisfies the requirement to 237 | distribute the source code, even though third parties are not 238 | compelled to copy the source along with the object code. 239 | 240 | 5. A program that contains no derivative of any portion of the 241 | Library, but is designed to work with the Library by being compiled or 242 | linked with it, is called a "work that uses the Library". Such a 243 | work, in isolation, is not a derivative work of the Library, and 244 | therefore falls outside the scope of this License. 245 | 246 | However, linking a "work that uses the Library" with the Library 247 | creates an executable that is a derivative of the Library (because it 248 | contains portions of the Library), rather than a "work that uses the 249 | library". The executable is therefore covered by this License. 250 | Section 6 states terms for distribution of such executables. 251 | 252 | When a "work that uses the Library" uses material from a header file 253 | that is part of the Library, the object code for the work may be a 254 | derivative work of the Library even though the source code is not. 255 | Whether this is true is especially significant if the work can be 256 | linked without the Library, or if the work is itself a library. The 257 | threshold for this to be true is not precisely defined by law. 258 | 259 | If such an object file uses only numerical parameters, data 260 | structure layouts and accessors, and small macros and small inline 261 | functions (ten lines or less in length), then the use of the object 262 | file is unrestricted, regardless of whether it is legally a derivative 263 | work. (Executables containing this object code plus portions of the 264 | Library will still fall under Section 6.) 265 | 266 | Otherwise, if the work is a derivative of the Library, you may 267 | distribute the object code for the work under the terms of Section 6. 268 | Any executables containing that work also fall under Section 6, 269 | whether or not they are linked directly with the Library itself. 270 | 271 | 6. As an exception to the Sections above, you may also combine or 272 | link a "work that uses the Library" with the Library to produce a 273 | work containing portions of the Library, and distribute that work 274 | under terms of your choice, provided that the terms permit 275 | modification of the work for the customer's own use and reverse 276 | engineering for debugging such modifications. 277 | 278 | You must give prominent notice with each copy of the work that the 279 | Library is used in it and that the Library and its use are covered by 280 | this License. You must supply a copy of this License. If the work 281 | during execution displays copyright notices, you must include the 282 | copyright notice for the Library among them, as well as a reference 283 | directing the user to the copy of this License. Also, you must do one 284 | of these things: 285 | 286 | a) Accompany the work with the complete corresponding 287 | machine-readable source code for the Library including whatever 288 | changes were used in the work (which must be distributed under 289 | Sections 1 and 2 above); and, if the work is an executable linked 290 | with the Library, with the complete machine-readable "work that 291 | uses the Library", as object code and/or source code, so that the 292 | user can modify the Library and then relink to produce a modified 293 | executable containing the modified Library. (It is understood 294 | that the user who changes the contents of definitions files in the 295 | Library will not necessarily be able to recompile the application 296 | to use the modified definitions.) 297 | 298 | b) Use a suitable shared library mechanism for linking with the 299 | Library. A suitable mechanism is one that (1) uses at run time a 300 | copy of the library already present on the user's computer system, 301 | rather than copying library functions into the executable, and (2) 302 | will operate properly with a modified version of the library, if 303 | the user installs one, as long as the modified version is 304 | interface-compatible with the version that the work was made with. 305 | 306 | c) Accompany the work with a written offer, valid for at 307 | least three years, to give the same user the materials 308 | specified in Subsection 6a, above, for a charge no more 309 | than the cost of performing this distribution. 310 | 311 | d) If distribution of the work is made by offering access to copy 312 | from a designated place, offer equivalent access to copy the above 313 | specified materials from the same place. 314 | 315 | e) Verify that the user has already received a copy of these 316 | materials or that you have already sent this user a copy. 317 | 318 | For an executable, the required form of the "work that uses the 319 | Library" must include any data and utility programs needed for 320 | reproducing the executable from it. However, as a special exception, 321 | the materials to be distributed need not include anything that is 322 | normally distributed (in either source or binary form) with the major 323 | components (compiler, kernel, and so on) of the operating system on 324 | which the executable runs, unless that component itself accompanies 325 | the executable. 326 | 327 | It may happen that this requirement contradicts the license 328 | restrictions of other proprietary libraries that do not normally 329 | accompany the operating system. Such a contradiction means you cannot 330 | use both them and the Library together in an executable that you 331 | distribute. 332 | 333 | 7. You may place library facilities that are a work based on the 334 | Library side-by-side in a single library together with other library 335 | facilities not covered by this License, and distribute such a combined 336 | library, provided that the separate distribution of the work based on 337 | the Library and of the other library facilities is otherwise 338 | permitted, and provided that you do these two things: 339 | 340 | a) Accompany the combined library with a copy of the same work 341 | based on the Library, uncombined with any other library 342 | facilities. This must be distributed under the terms of the 343 | Sections above. 344 | 345 | b) Give prominent notice with the combined library of the fact 346 | that part of it is a work based on the Library, and explaining 347 | where to find the accompanying uncombined form of the same work. 348 | 349 | 8. You may not copy, modify, sublicense, link with, or distribute 350 | the Library except as expressly provided under this License. Any 351 | attempt otherwise to copy, modify, sublicense, link with, or 352 | distribute the Library is void, and will automatically terminate your 353 | rights under this License. However, parties who have received copies, 354 | or rights, from you under this License will not have their licenses 355 | terminated so long as such parties remain in full compliance. 356 | 357 | 9. You are not required to accept this License, since you have not 358 | signed it. However, nothing else grants you permission to modify or 359 | distribute the Library or its derivative works. These actions are 360 | prohibited by law if you do not accept this License. Therefore, by 361 | modifying or distributing the Library (or any work based on the 362 | Library), you indicate your acceptance of this License to do so, and 363 | all its terms and conditions for copying, distributing or modifying 364 | the Library or works based on it. 365 | 366 | 10. Each time you redistribute the Library (or any work based on the 367 | Library), the recipient automatically receives a license from the 368 | original licensor to copy, distribute, link with or modify the Library 369 | subject to these terms and conditions. You may not impose any further 370 | restrictions on the recipients' exercise of the rights granted herein. 371 | You are not responsible for enforcing compliance by third parties with 372 | this License. 373 | 374 | 11. If, as a consequence of a court judgment or allegation of patent 375 | infringement or for any other reason (not limited to patent issues), 376 | conditions are imposed on you (whether by court order, agreement or 377 | otherwise) that contradict the conditions of this License, they do not 378 | excuse you from the conditions of this License. If you cannot 379 | distribute so as to satisfy simultaneously your obligations under this 380 | License and any other pertinent obligations, then as a consequence you 381 | may not distribute the Library at all. For example, if a patent 382 | license would not permit royalty-free redistribution of the Library by 383 | all those who receive copies directly or indirectly through you, then 384 | the only way you could satisfy both it and this License would be to 385 | refrain entirely from distribution of the Library. 386 | 387 | If any portion of this section is held invalid or unenforceable under any 388 | particular circumstance, the balance of the section is intended to apply, 389 | and the section as a whole is intended to apply in other circumstances. 390 | 391 | It is not the purpose of this section to induce you to infringe any 392 | patents or other property right claims or to contest validity of any 393 | such claims; this section has the sole purpose of protecting the 394 | integrity of the free software distribution system which is 395 | implemented by public license practices. Many people have made 396 | generous contributions to the wide range of software distributed 397 | through that system in reliance on consistent application of that 398 | system; it is up to the author/donor to decide if he or she is willing 399 | to distribute software through any other system and a licensee cannot 400 | impose that choice. 401 | 402 | This section is intended to make thoroughly clear what is believed to 403 | be a consequence of the rest of this License. 404 | 405 | 12. If the distribution and/or use of the Library is restricted in 406 | certain countries either by patents or by copyrighted interfaces, the 407 | original copyright holder who places the Library under this License may add 408 | an explicit geographical distribution limitation excluding those countries, 409 | so that distribution is permitted only in or among countries not thus 410 | excluded. In such case, this License incorporates the limitation as if 411 | written in the body of this License. 412 | 413 | 13. The Free Software Foundation may publish revised and/or new 414 | versions of the Lesser General Public License from time to time. 415 | Such new versions will be similar in spirit to the present version, 416 | but may differ in detail to address new problems or concerns. 417 | 418 | Each version is given a distinguishing version number. If the Library 419 | specifies a version number of this License which applies to it and 420 | "any later version", you have the option of following the terms and 421 | conditions either of that version or of any later version published by 422 | the Free Software Foundation. If the Library does not specify a 423 | license version number, you may choose any version ever published by 424 | the Free Software Foundation. 425 | 426 | 14. If you wish to incorporate parts of the Library into other free 427 | programs whose distribution conditions are incompatible with these, 428 | write to the author to ask for permission. For software which is 429 | copyrighted by the Free Software Foundation, write to the Free 430 | Software Foundation; we sometimes make exceptions for this. Our 431 | decision will be guided by the two goals of preserving the free status 432 | of all derivatives of our free software and of promoting the sharing 433 | and reuse of software generally. 434 | 435 | NO WARRANTY 436 | 437 | 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO 438 | WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. 439 | EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR 440 | OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY 441 | KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE 442 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 443 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE 444 | LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME 445 | THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 446 | 447 | 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN 448 | WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY 449 | AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU 450 | FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR 451 | CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE 452 | LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING 453 | RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A 454 | FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF 455 | SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH 456 | DAMAGES. 457 | 458 | END OF TERMS AND CONDITIONS 459 | 460 | How to Apply These Terms to Your New Libraries 461 | 462 | If you develop a new library, and you want it to be of the greatest 463 | possible use to the public, we recommend making it free software that 464 | everyone can redistribute and change. You can do so by permitting 465 | redistribution under these terms (or, alternatively, under the terms of the 466 | ordinary General Public License). 467 | 468 | To apply these terms, attach the following notices to the library. It is 469 | safest to attach them to the start of each source file to most effectively 470 | convey the exclusion of warranty; and each file should have at least the 471 | "copyright" line and a pointer to where the full notice is found. 472 | 473 | 474 | Copyright (C) 475 | 476 | This library is free software; you can redistribute it and/or 477 | modify it under the terms of the GNU Lesser General Public 478 | License as published by the Free Software Foundation; either 479 | version 2.1 of the License, or (at your option) any later version. 480 | 481 | This library is distributed in the hope that it will be useful, 482 | but WITHOUT ANY WARRANTY; without even the implied warranty of 483 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 484 | Lesser General Public License for more details. 485 | 486 | You should have received a copy of the GNU Lesser General Public 487 | License along with this library; if not, write to the Free Software 488 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 489 | 490 | Also add information on how to contact you by electronic and paper mail. 491 | 492 | You should also get your employer (if you work as a programmer) or your 493 | school, if any, to sign a "copyright disclaimer" for the library, if 494 | necessary. Here is a sample; alter the names: 495 | 496 | Yoyodyne, Inc., hereby disclaims all copyright interest in the 497 | library `Frob' (a library for tweaking knobs) written by James Random Hacker. 498 | 499 | , 1 April 1990 500 | Ty Coon, President of Vice 501 | 502 | That's all there is to it! 503 | -------------------------------------------------------------------------------- /ChangeLog: -------------------------------------------------------------------------------- 1 | 2010-03-31 Cameron Zemek 2 | * *.c: Changed to use stdint.h for fixed width integer types 3 | * common.h: Changed interpolate functions to work with 24bit color 4 | * init.c: Changed RGBtoYUV table to convert 24bit color values 5 | * hqx.c: Created command line tool that uses DevIL 6 | 7 | 2011-12-05 Cameron Zemek 8 | * Thanks for this change go to anbaricforce 9 | * hqx.h: Added declarations for row byte versions 10 | * hq*x.c: Added version of function that takes row bytes 11 | 12 | 2011-12-05 Cameron Zemek , Francois Gannaz 13 | * Added transparency support 14 | -------------------------------------------------------------------------------- /INSTALL: -------------------------------------------------------------------------------- 1 | Installation Instructions 2 | ************************* 3 | 4 | Copyright (C) 1994-1996, 1999-2002, 2004-2017, 2020-2021 Free 5 | Software Foundation, Inc. 6 | 7 | Copying and distribution of this file, with or without modification, 8 | are permitted in any medium without royalty provided the copyright 9 | notice and this notice are preserved. This file is offered as-is, 10 | without warranty of any kind. 11 | 12 | Basic Installation 13 | ================== 14 | 15 | Briefly, the shell command './configure && make && make install' 16 | should configure, build, and install this package. The following 17 | more-detailed instructions are generic; see the 'README' file for 18 | instructions specific to this package. Some packages provide this 19 | 'INSTALL' file but do not implement all of the features documented 20 | below. The lack of an optional feature in a given package is not 21 | necessarily a bug. More recommendations for GNU packages can be found 22 | in *note Makefile Conventions: (standards)Makefile Conventions. 23 | 24 | The 'configure' shell script attempts to guess correct values for 25 | various system-dependent variables used during compilation. It uses 26 | those values to create a 'Makefile' in each directory of the package. 27 | It may also create one or more '.h' files containing system-dependent 28 | definitions. Finally, it creates a shell script 'config.status' that 29 | you can run in the future to recreate the current configuration, and a 30 | file 'config.log' containing compiler output (useful mainly for 31 | debugging 'configure'). 32 | 33 | It can also use an optional file (typically called 'config.cache' and 34 | enabled with '--cache-file=config.cache' or simply '-C') that saves the 35 | results of its tests to speed up reconfiguring. Caching is disabled by 36 | default to prevent problems with accidental use of stale cache files. 37 | 38 | If you need to do unusual things to compile the package, please try 39 | to figure out how 'configure' could check whether to do them, and mail 40 | diffs or instructions to the address given in the 'README' so they can 41 | be considered for the next release. If you are using the cache, and at 42 | some point 'config.cache' contains results you don't want to keep, you 43 | may remove or edit it. 44 | 45 | The file 'configure.ac' (or 'configure.in') is used to create 46 | 'configure' by a program called 'autoconf'. You need 'configure.ac' if 47 | you want to change it or regenerate 'configure' using a newer version of 48 | 'autoconf'. 49 | 50 | The simplest way to compile this package is: 51 | 52 | 1. 'cd' to the directory containing the package's source code and type 53 | './configure' to configure the package for your system. 54 | 55 | Running 'configure' might take a while. While running, it prints 56 | some messages telling which features it is checking for. 57 | 58 | 2. Type 'make' to compile the package. 59 | 60 | 3. Optionally, type 'make check' to run any self-tests that come with 61 | the package, generally using the just-built uninstalled binaries. 62 | 63 | 4. Type 'make install' to install the programs and any data files and 64 | documentation. When installing into a prefix owned by root, it is 65 | recommended that the package be configured and built as a regular 66 | user, and only the 'make install' phase executed with root 67 | privileges. 68 | 69 | 5. Optionally, type 'make installcheck' to repeat any self-tests, but 70 | this time using the binaries in their final installed location. 71 | This target does not install anything. Running this target as a 72 | regular user, particularly if the prior 'make install' required 73 | root privileges, verifies that the installation completed 74 | correctly. 75 | 76 | 6. You can remove the program binaries and object files from the 77 | source code directory by typing 'make clean'. To also remove the 78 | files that 'configure' created (so you can compile the package for 79 | a different kind of computer), type 'make distclean'. There is 80 | also a 'make maintainer-clean' target, but that is intended mainly 81 | for the package's developers. If you use it, you may have to get 82 | all sorts of other programs in order to regenerate files that came 83 | with the distribution. 84 | 85 | 7. Often, you can also type 'make uninstall' to remove the installed 86 | files again. In practice, not all packages have tested that 87 | uninstallation works correctly, even though it is required by the 88 | GNU Coding Standards. 89 | 90 | 8. Some packages, particularly those that use Automake, provide 'make 91 | distcheck', which can by used by developers to test that all other 92 | targets like 'make install' and 'make uninstall' work correctly. 93 | This target is generally not run by end users. 94 | 95 | Compilers and Options 96 | ===================== 97 | 98 | Some systems require unusual options for compilation or linking that 99 | the 'configure' script does not know about. Run './configure --help' 100 | for details on some of the pertinent environment variables. 101 | 102 | You can give 'configure' initial values for configuration parameters 103 | by setting variables in the command line or in the environment. Here is 104 | an example: 105 | 106 | ./configure CC=c99 CFLAGS=-g LIBS=-lposix 107 | 108 | *Note Defining Variables::, for more details. 109 | 110 | Compiling For Multiple Architectures 111 | ==================================== 112 | 113 | You can compile the package for more than one kind of computer at the 114 | same time, by placing the object files for each architecture in their 115 | own directory. To do this, you can use GNU 'make'. 'cd' to the 116 | directory where you want the object files and executables to go and run 117 | the 'configure' script. 'configure' automatically checks for the source 118 | code in the directory that 'configure' is in and in '..'. This is known 119 | as a "VPATH" build. 120 | 121 | With a non-GNU 'make', it is safer to compile the package for one 122 | architecture at a time in the source code directory. After you have 123 | installed the package for one architecture, use 'make distclean' before 124 | reconfiguring for another architecture. 125 | 126 | On MacOS X 10.5 and later systems, you can create libraries and 127 | executables that work on multiple system types--known as "fat" or 128 | "universal" binaries--by specifying multiple '-arch' options to the 129 | compiler but only a single '-arch' option to the preprocessor. Like 130 | this: 131 | 132 | ./configure CC="gcc -arch i386 -arch x86_64 -arch ppc -arch ppc64" \ 133 | CXX="g++ -arch i386 -arch x86_64 -arch ppc -arch ppc64" \ 134 | CPP="gcc -E" CXXCPP="g++ -E" 135 | 136 | This is not guaranteed to produce working output in all cases, you 137 | may have to build one architecture at a time and combine the results 138 | using the 'lipo' tool if you have problems. 139 | 140 | Installation Names 141 | ================== 142 | 143 | By default, 'make install' installs the package's commands under 144 | '/usr/local/bin', include files under '/usr/local/include', etc. You 145 | can specify an installation prefix other than '/usr/local' by giving 146 | 'configure' the option '--prefix=PREFIX', where PREFIX must be an 147 | absolute file name. 148 | 149 | You can specify separate installation prefixes for 150 | architecture-specific files and architecture-independent files. If you 151 | pass the option '--exec-prefix=PREFIX' to 'configure', the package uses 152 | PREFIX as the prefix for installing programs and libraries. 153 | Documentation and other data files still use the regular prefix. 154 | 155 | In addition, if you use an unusual directory layout you can give 156 | options like '--bindir=DIR' to specify different values for particular 157 | kinds of files. Run 'configure --help' for a list of the directories 158 | you can set and what kinds of files go in them. In general, the default 159 | for these options is expressed in terms of '${prefix}', so that 160 | specifying just '--prefix' will affect all of the other directory 161 | specifications that were not explicitly provided. 162 | 163 | The most portable way to affect installation locations is to pass the 164 | correct locations to 'configure'; however, many packages provide one or 165 | both of the following shortcuts of passing variable assignments to the 166 | 'make install' command line to change installation locations without 167 | having to reconfigure or recompile. 168 | 169 | The first method involves providing an override variable for each 170 | affected directory. For example, 'make install 171 | prefix=/alternate/directory' will choose an alternate location for all 172 | directory configuration variables that were expressed in terms of 173 | '${prefix}'. Any directories that were specified during 'configure', 174 | but not in terms of '${prefix}', must each be overridden at install time 175 | for the entire installation to be relocated. The approach of makefile 176 | variable overrides for each directory variable is required by the GNU 177 | Coding Standards, and ideally causes no recompilation. However, some 178 | platforms have known limitations with the semantics of shared libraries 179 | that end up requiring recompilation when using this method, particularly 180 | noticeable in packages that use GNU Libtool. 181 | 182 | The second method involves providing the 'DESTDIR' variable. For 183 | example, 'make install DESTDIR=/alternate/directory' will prepend 184 | '/alternate/directory' before all installation names. The approach of 185 | 'DESTDIR' overrides is not required by the GNU Coding Standards, and 186 | does not work on platforms that have drive letters. On the other hand, 187 | it does better at avoiding recompilation issues, and works well even 188 | when some directory options were not specified in terms of '${prefix}' 189 | at 'configure' time. 190 | 191 | Optional Features 192 | ================= 193 | 194 | If the package supports it, you can cause programs to be installed 195 | with an extra prefix or suffix on their names by giving 'configure' the 196 | option '--program-prefix=PREFIX' or '--program-suffix=SUFFIX'. 197 | 198 | Some packages pay attention to '--enable-FEATURE' options to 199 | 'configure', where FEATURE indicates an optional part of the package. 200 | They may also pay attention to '--with-PACKAGE' options, where PACKAGE 201 | is something like 'gnu-as' or 'x' (for the X Window System). The 202 | 'README' should mention any '--enable-' and '--with-' options that the 203 | package recognizes. 204 | 205 | For packages that use the X Window System, 'configure' can usually 206 | find the X include and library files automatically, but if it doesn't, 207 | you can use the 'configure' options '--x-includes=DIR' and 208 | '--x-libraries=DIR' to specify their locations. 209 | 210 | Some packages offer the ability to configure how verbose the 211 | execution of 'make' will be. For these packages, running './configure 212 | --enable-silent-rules' sets the default to minimal output, which can be 213 | overridden with 'make V=1'; while running './configure 214 | --disable-silent-rules' sets the default to verbose, which can be 215 | overridden with 'make V=0'. 216 | 217 | Particular systems 218 | ================== 219 | 220 | On HP-UX, the default C compiler is not ANSI C compatible. If GNU CC 221 | is not installed, it is recommended to use the following options in 222 | order to use an ANSI C compiler: 223 | 224 | ./configure CC="cc -Ae -D_XOPEN_SOURCE=500" 225 | 226 | and if that doesn't work, install pre-built binaries of GCC for HP-UX. 227 | 228 | HP-UX 'make' updates targets which have the same timestamps as their 229 | prerequisites, which makes it generally unusable when shipped generated 230 | files such as 'configure' are involved. Use GNU 'make' instead. 231 | 232 | On OSF/1 a.k.a. Tru64, some versions of the default C compiler cannot 233 | parse its '' header file. The option '-nodtk' can be used as a 234 | workaround. If GNU CC is not installed, it is therefore recommended to 235 | try 236 | 237 | ./configure CC="cc" 238 | 239 | and if that doesn't work, try 240 | 241 | ./configure CC="cc -nodtk" 242 | 243 | On Solaris, don't put '/usr/ucb' early in your 'PATH'. This 244 | directory contains several dysfunctional programs; working variants of 245 | these programs are available in '/usr/bin'. So, if you need '/usr/ucb' 246 | in your 'PATH', put it _after_ '/usr/bin'. 247 | 248 | On Haiku, software installed for all users goes in '/boot/common', 249 | not '/usr/local'. It is recommended to use the following options: 250 | 251 | ./configure --prefix=/boot/common 252 | 253 | Specifying the System Type 254 | ========================== 255 | 256 | There may be some features 'configure' cannot figure out 257 | automatically, but needs to determine by the type of machine the package 258 | will run on. Usually, assuming the package is built to be run on the 259 | _same_ architectures, 'configure' can figure that out, but if it prints 260 | a message saying it cannot guess the machine type, give it the 261 | '--build=TYPE' option. TYPE can either be a short name for the system 262 | type, such as 'sun4', or a canonical name which has the form: 263 | 264 | CPU-COMPANY-SYSTEM 265 | 266 | where SYSTEM can have one of these forms: 267 | 268 | OS 269 | KERNEL-OS 270 | 271 | See the file 'config.sub' for the possible values of each field. If 272 | 'config.sub' isn't included in this package, then this package doesn't 273 | need to know the machine type. 274 | 275 | If you are _building_ compiler tools for cross-compiling, you should 276 | use the option '--target=TYPE' to select the type of system they will 277 | produce code for. 278 | 279 | If you want to _use_ a cross compiler, that generates code for a 280 | platform different from the build platform, you should specify the 281 | "host" platform (i.e., that on which the generated programs will 282 | eventually be run) with '--host=TYPE'. 283 | 284 | Sharing Defaults 285 | ================ 286 | 287 | If you want to set default values for 'configure' scripts to share, 288 | you can create a site shell script called 'config.site' that gives 289 | default values for variables like 'CC', 'cache_file', and 'prefix'. 290 | 'configure' looks for 'PREFIX/share/config.site' if it exists, then 291 | 'PREFIX/etc/config.site' if it exists. Or, you can set the 292 | 'CONFIG_SITE' environment variable to the location of the site script. 293 | A warning: not all 'configure' scripts look for a site script. 294 | 295 | Defining Variables 296 | ================== 297 | 298 | Variables not defined in a site shell script can be set in the 299 | environment passed to 'configure'. However, some packages may run 300 | configure again during the build, and the customized values of these 301 | variables may be lost. In order to avoid this problem, you should set 302 | them in the 'configure' command line, using 'VAR=value'. For example: 303 | 304 | ./configure CC=/usr/local2/bin/gcc 305 | 306 | causes the specified 'gcc' to be used as the C compiler (unless it is 307 | overridden in the site shell script). 308 | 309 | Unfortunately, this technique does not work for 'CONFIG_SHELL' due to an 310 | Autoconf limitation. Until the limitation is lifted, you can use this 311 | workaround: 312 | 313 | CONFIG_SHELL=/bin/bash ./configure CONFIG_SHELL=/bin/bash 314 | 315 | 'configure' Invocation 316 | ====================== 317 | 318 | 'configure' recognizes the following options to control how it 319 | operates. 320 | 321 | '--help' 322 | '-h' 323 | Print a summary of all of the options to 'configure', and exit. 324 | 325 | '--help=short' 326 | '--help=recursive' 327 | Print a summary of the options unique to this package's 328 | 'configure', and exit. The 'short' variant lists options used only 329 | in the top level, while the 'recursive' variant lists options also 330 | present in any nested packages. 331 | 332 | '--version' 333 | '-V' 334 | Print the version of Autoconf used to generate the 'configure' 335 | script, and exit. 336 | 337 | '--cache-file=FILE' 338 | Enable the cache: use and save the results of the tests in FILE, 339 | traditionally 'config.cache'. FILE defaults to '/dev/null' to 340 | disable caching. 341 | 342 | '--config-cache' 343 | '-C' 344 | Alias for '--cache-file=config.cache'. 345 | 346 | '--quiet' 347 | '--silent' 348 | '-q' 349 | Do not print messages saying which checks are being made. To 350 | suppress all normal output, redirect it to '/dev/null' (any error 351 | messages will still be shown). 352 | 353 | '--srcdir=DIR' 354 | Look for the package's source code in directory DIR. Usually 355 | 'configure' can determine that directory automatically. 356 | 357 | '--prefix=DIR' 358 | Use DIR as the installation prefix. *note Installation Names:: for 359 | more details, including other options available for fine-tuning the 360 | installation locations. 361 | 362 | '--no-create' 363 | '-n' 364 | Run the configure checks, but stop before creating any output 365 | files. 366 | 367 | 'configure' also accepts some other, not widely useful, options. Run 368 | 'configure --help' for more details. 369 | -------------------------------------------------------------------------------- /Makefile.am: -------------------------------------------------------------------------------- 1 | ACLOCAL_AMFLAGS = -I m4 2 | 3 | SUBDIRS = src 4 | -------------------------------------------------------------------------------- /NEWS: -------------------------------------------------------------------------------- 1 | These are just highlights of what was changed during each release. For a more 2 | in-depth version of what was changed, please look at the ChangeLog. 3 | 4 | 1.0 5 | --- 6 | - Added support for 24 bit color 7 | - Created command line tool that uses DevIL library for loading/saving images 8 | - Use autotools for build system 9 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | hqx Library README 2 | ================== 3 | 4 | Introduction 5 | ------------ 6 | hqx is a fast, high-quality magnification filter designed for pixel art. 7 | 8 | Install 9 | ------- 10 | NOTE: DevIL library and development headers are required. 11 | 12 | ./configure 13 | make && make install 14 | 15 | For more information refer to INSTALL. 16 | 17 | Usage 18 | ----- 19 | hqx -s scaleBy input output 20 | Where scaleBy is either 2, 3 or 4 21 | 22 | For example: 23 | hqx -s 4 test.png out.png 24 | 25 | Example 26 | ------- 27 | #include 28 | #include 29 | 30 | uint32_t *src; // Pointer to source bitmap in RGB format 31 | size_t width, height; // Size of source bitmap 32 | 33 | /* 34 | * Code to init src, width & height 35 | */ 36 | 37 | uint32_t *dest = (uint32_t *) malloc(width * 4 * height * 4 * sizeof(uint32_t)); 38 | hqxInit(); 39 | hq4x_32(src, dest, width, height); 40 | 41 | Implementation 42 | -------------- 43 | The first step is an analysis of the 3x3 area of the source pixel. At first, we 44 | calculate the color difference between the central pixel and its 8 nearest 45 | neighbors. Then that difference is compared to a predefined threshold, and these 46 | pixels are sorted into two categories: "close" and "distant" colored. There are 47 | 8 neighbors, so we are getting 256 possible combinations. 48 | 49 | For the next step, which is filtering, a lookup table with 256 entries is used, 50 | one entry per each combination of close/distant colored neighbors. Each entry 51 | describes how to mix the colors of the source pixels from 3x3 area to get 52 | interpolated pixels of the filtered image. 53 | 54 | The present implementation is using YUV color space to calculate color 55 | differences, with more tolerance on Y (brightness) component, then on color 56 | components U and V. That color space conversion is quite easy to implement if 57 | the format of the source image is 16 bit per pixel, using a simple lookup table. 58 | It is also possible to calculate the color differences and compare them to a 59 | threshold very fast, using MMX instructions. 60 | 61 | Creating a lookup table was the most difficult part - for each combination the 62 | most probable vector representation of the area has to be determined, with the 63 | idea of edges between the different colored areas of the image to be preserved, 64 | with the edge direction to be as close to a correct one as possible. That vector 65 | representation is then rasterised with higher (3x) resolution using 66 | anti-aliasing, and the result is stored in the lookup table. 67 | 68 | The filter was not designed for photographs, but for images with clear sharp 69 | edges, like line graphics or cartoon sprites. It was also designed to be fast 70 | enough to process 256x256 images in real-time. 71 | -------------------------------------------------------------------------------- /configure.ac: -------------------------------------------------------------------------------- 1 | AC_INIT([hqx],[1.0],[grom@zeminvaders.net]) 2 | AC_CONFIG_MACRO_DIR([m4]) 3 | AM_PROG_AR 4 | AC_PROG_CC 5 | AC_LANG([C]) 6 | AC_C_INLINE 7 | AC_C_BIGENDIAN 8 | AM_INIT_AUTOMAKE([-Wall -Werror]) 9 | AM_PROG_CC_C_O 10 | 11 | AC_CHECK_HEADER([IL/il.h],,AC_MSG_ERROR("DevIL il.h required")) 12 | 13 | AC_ARG_ENABLE([debug], 14 | [AS_HELP_STRING([--enable-debug], [Compile a debug version of the library])], 15 | [CFLAGS="-Wall -g -O0"], 16 | [CFLAGS="-O3"]) 17 | 18 | LT_INIT([win32-dll]) 19 | HQX_LTVERSION=1:0:0 20 | AC_SUBST([HQX_LTVERSION]) 21 | 22 | dnl Win32 23 | AS_CASE([$host], 24 | [*mingw32*], [PLATFORM="MINGW32"], 25 | [*cygwin*], [CFLAGS="$CFLAGS -mno-cygwin" PLATFORM="CYGWIN"], 26 | [*darwin*], [PLATFORM="OSX"]) 27 | AC_SUBST([PLATFORM]) 28 | 29 | AM_CONDITIONAL([WINDOWS_BUILD], 30 | [test "x$PLATFORM" = "xMINGW32" -o "x$PLATFORM" = "xCYGWIN"]) 31 | 32 | AC_CONFIG_FILES([Makefile src/Makefile]) 33 | AC_CONFIG_HEADERS([src/config.h]) 34 | AC_OUTPUT 35 | -------------------------------------------------------------------------------- /debian/changelog: -------------------------------------------------------------------------------- 1 | libhqx (1.1) unstable; urgency=low 2 | 3 | * Initial Release. 4 | 5 | -- James E. Flemer Mon, 19 Nov 2012 17:36:32 -0700 6 | -------------------------------------------------------------------------------- /debian/compat: -------------------------------------------------------------------------------- 1 | 10 2 | -------------------------------------------------------------------------------- /debian/control: -------------------------------------------------------------------------------- 1 | Source: libhqx 2 | Priority: optional 3 | Maintainer: James E. Flemer 4 | Build-Depends: debhelper (>= 8.0.0), autotools-dev, libdevil-dev 5 | Standards-Version: 3.9.2 6 | Section: graphics 7 | Homepage: http://code.google.com/p/hqx/ 8 | Vcs-Svn: http://hqx.googlecode.com/svn/trunk/ 9 | Vcs-Browser: http://code.google.com/p/hqx/source/browse/#svn%2Ftrunk 10 | 11 | Package: libhqx1 12 | Section: libs 13 | Architecture: any 14 | Depends: ${shlibs:Depends}, ${misc:Depends} 15 | Description: fast, high-quality magnification filter for pixel art 16 | hqx ("hq" stands for "high quality" and "x" stands for magnification) 17 | is one of the pixel art scaling algorithms developed by Maxim Stepin, 18 | used in emulators such as Nestopia, bsnes, ZSNES, Snes9x, FCE Ultra 19 | and many more. There are 3 hqx filters: hq2x, hq3x and hq4x which 20 | magnify by factor of 2, 3 and 4 respectively. 21 | . 22 | libhqx shared library 23 | 24 | Package: libhqx-dev 25 | Section: libdevel 26 | Architecture: any 27 | Depends: libhqx1 (= ${binary:Version}) 28 | Description: fast, high-quality magnification filter for pixel art 29 | hqx ("hq" stands for "high quality" and "x" stands for magnification) 30 | is one of the pixel art scaling algorithms developed by Maxim Stepin, 31 | used in emulators such as Nestopia, bsnes, ZSNES, Snes9x, FCE Ultra 32 | and many more. There are 3 hqx filters: hq2x, hq3x and hq4x which 33 | magnify by factor of 2, 3 and 4 respectively. 34 | . 35 | libhqx headers and static library 36 | 37 | Package: libhqx-bin 38 | Section: graphics 39 | Architecture: any 40 | Depends: libhqx1 (= ${binary:Version}), ${shlibs:Depends}, ${misc:Depends} 41 | Description: fast, high-quality magnification filter for pixel art 42 | hqx ("hq" stands for "high quality" and "x" stands for magnification) 43 | is one of the pixel art scaling algorithms developed by Maxim Stepin, 44 | used in emulators such as Nestopia, bsnes, ZSNES, Snes9x, FCE Ultra 45 | and many more. There are 3 hqx filters: hq2x, hq3x and hq4x which 46 | magnify by factor of 2, 3 and 4 respectively. 47 | . 48 | hqx command line tool 49 | -------------------------------------------------------------------------------- /debian/copyright: -------------------------------------------------------------------------------- 1 | Format: http://dep.debian.net/deps/dep5 2 | Upstream-Name: libhqx 3 | Source: http://code.google.com/p/hqx/ 4 | 5 | Files: * 6 | Copyright: 2003 Maxim Stepin 7 | 2010 Cameron Zemek 8 | 2011 Francois Gannaz 9 | License: LGPL-2.1+ 10 | 11 | Files: debian/* 12 | Copyright: 2012 James E. Flemer 13 | License: LGPL-2.1+ 14 | 15 | License: LGPL-2.1+ 16 | This package is free software; you can redistribute it and/or 17 | modify it under the terms of the GNU Lesser General Public 18 | License as published by the Free Software Foundation; either 19 | version 2.1 of the License, or (at your option) any later version. 20 | . 21 | This package is distributed in the hope that it will be useful, 22 | but WITHOUT ANY WARRANTY; without even the implied warranty of 23 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 24 | Lesser General Public License for more details. 25 | . 26 | You should have received a copy of the GNU General Public License 27 | along with this program. If not, see . 28 | . 29 | On Debian systems, the complete text of the GNU Lesser General 30 | Public License can be found in "/usr/share/common-licenses/LGPL-2.1". 31 | 32 | # Please also look if there are files or directories which have a 33 | # different copyright/license attached and list them here. 34 | -------------------------------------------------------------------------------- /debian/docs: -------------------------------------------------------------------------------- 1 | AUTHORS 2 | COPYING 3 | NEWS 4 | README 5 | -------------------------------------------------------------------------------- /debian/libhqx-bin.dirs: -------------------------------------------------------------------------------- 1 | usr/bin 2 | -------------------------------------------------------------------------------- /debian/libhqx-bin.install: -------------------------------------------------------------------------------- 1 | usr/bin/* 2 | -------------------------------------------------------------------------------- /debian/libhqx-dev.dirs: -------------------------------------------------------------------------------- 1 | usr/lib 2 | usr/include 3 | usr/include/hqx 4 | -------------------------------------------------------------------------------- /debian/libhqx-dev.install: -------------------------------------------------------------------------------- 1 | usr/include/hqx/* 2 | usr/lib/*/lib*.a 3 | usr/lib/*/lib*.so 4 | -------------------------------------------------------------------------------- /debian/libhqx1.dirs: -------------------------------------------------------------------------------- 1 | usr/lib 2 | -------------------------------------------------------------------------------- /debian/libhqx1.install: -------------------------------------------------------------------------------- 1 | usr/lib/*/lib*.so.* 2 | -------------------------------------------------------------------------------- /debian/rules: -------------------------------------------------------------------------------- 1 | #!/usr/bin/make -f 2 | # -*- makefile -*- 3 | 4 | # Uncomment this to turn on verbose mode. 5 | #export DH_VERBOSE=1 6 | 7 | %: 8 | dh $@ 9 | 10 | override_dh_auto_configure: 11 | dh_auto_configure -- --includedir=/usr/include/hqx 12 | -------------------------------------------------------------------------------- /src/Makefile.am: -------------------------------------------------------------------------------- 1 | lib_LTLIBRARIES = libhqx.la 2 | libhqx_la_LDFLAGS = -version-info @HQX_LTVERSION@ 3 | if WINDOWS_BUILD 4 | libhqx_la_LDFLAGS += -no-undefined 5 | endif 6 | libhqx_la_SOURCES = init.c hq2x.c hq3x.c hq4x.c common.h 7 | include_HEADERS = hqx.h 8 | 9 | bin_PROGRAMS = hqx 10 | hqx_SOURCES = hqx.c 11 | hqx_CPPFLAGS = -I. 12 | hqx_LDADD = -lIL libhqx.la 13 | -------------------------------------------------------------------------------- /src/common.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2003 Maxim Stepin ( maxst@hiend3d.com ) 3 | * 4 | * Copyright (C) 2010 Cameron Zemek ( grom@zeminvaders.net) 5 | * Copyright (C) 2011 Francois Gannaz 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU Lesser General Public 9 | * License as published by the Free Software Foundation; either 10 | * version 2.1 of the License, or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 | */ 21 | 22 | #ifndef __HQX_COMMON_H_ 23 | #define __HQX_COMMON_H_ 24 | 25 | #include 26 | #include 27 | 28 | #define MASK_2 0x0000FF00 29 | #define MASK_13 0x00FF00FF 30 | #define MASK_RGB 0x00FFFFFF 31 | #define MASK_ALPHA 0xFF000000 32 | 33 | #define Ymask 0x00FF0000 34 | #define Umask 0x0000FF00 35 | #define Vmask 0x000000FF 36 | #define trY 0x00300000 37 | #define trU 0x00000700 38 | #define trV 0x00000006 39 | 40 | /* RGB to YUV lookup table */ 41 | extern uint32_t RGBtoYUV[16777216]; 42 | 43 | static inline uint32_t rgb_to_yuv(uint32_t c) 44 | { 45 | // Mask against MASK_RGB to discard the alpha channel 46 | return RGBtoYUV[MASK_RGB & c]; 47 | } 48 | 49 | /* Test if there is difference in color */ 50 | static inline int yuv_diff(uint32_t yuv1, uint32_t yuv2) { 51 | return (( abs((yuv1 & Ymask) - (yuv2 & Ymask)) > trY ) || 52 | ( abs((yuv1 & Umask) - (yuv2 & Umask)) > trU ) || 53 | ( abs((yuv1 & Vmask) - (yuv2 & Vmask)) > trV ) ); 54 | } 55 | 56 | static inline int Diff(uint32_t c1, uint32_t c2) 57 | { 58 | return yuv_diff(rgb_to_yuv(c1), rgb_to_yuv(c2)); 59 | } 60 | 61 | /* Interpolate functions */ 62 | static inline uint32_t Interpolate_2(uint32_t c1, int w1, uint32_t c2, int w2, int s) 63 | { 64 | if (c1 == c2) { 65 | return c1; 66 | } 67 | return 68 | (((((c1 & MASK_ALPHA) >> 24) * w1 + ((c2 & MASK_ALPHA) >> 24) * w2) << (24-s)) & MASK_ALPHA) + 69 | ((((c1 & MASK_2) * w1 + (c2 & MASK_2) * w2) >> s) & MASK_2) + 70 | ((((c1 & MASK_13) * w1 + (c2 & MASK_13) * w2) >> s) & MASK_13); 71 | } 72 | 73 | static inline uint32_t Interpolate_3(uint32_t c1, int w1, uint32_t c2, int w2, uint32_t c3, int w3, int s) 74 | { 75 | return 76 | (((((c1 & MASK_ALPHA) >> 24) * w1 + ((c2 & MASK_ALPHA) >> 24) * w2 + ((c3 & MASK_ALPHA) >> 24) * w3) << (24-s)) & MASK_ALPHA) + 77 | ((((c1 & MASK_2) * w1 + (c2 & MASK_2) * w2 + (c3 & MASK_2) * w3) >> s) & MASK_2) + 78 | ((((c1 & MASK_13) * w1 + (c2 & MASK_13) * w2 + (c3 & MASK_13) * w3) >> s) & MASK_13); 79 | } 80 | 81 | static inline void Interp1(uint32_t * pc, uint32_t c1, uint32_t c2) 82 | { 83 | //*pc = (c1*3+c2) >> 2; 84 | *pc = Interpolate_2(c1, 3, c2, 1, 2); 85 | } 86 | 87 | static inline void Interp2(uint32_t * pc, uint32_t c1, uint32_t c2, uint32_t c3) 88 | { 89 | //*pc = (c1*2+c2+c3) >> 2; 90 | *pc = Interpolate_3(c1, 2, c2, 1, c3, 1, 2); 91 | } 92 | 93 | static inline void Interp3(uint32_t * pc, uint32_t c1, uint32_t c2) 94 | { 95 | //*pc = (c1*7+c2)/8; 96 | *pc = Interpolate_2(c1, 7, c2, 1, 3); 97 | } 98 | 99 | static inline void Interp4(uint32_t * pc, uint32_t c1, uint32_t c2, uint32_t c3) 100 | { 101 | //*pc = (c1*2+(c2+c3)*7)/16; 102 | *pc = Interpolate_3(c1, 2, c2, 7, c3, 7, 4); 103 | } 104 | 105 | static inline void Interp5(uint32_t * pc, uint32_t c1, uint32_t c2) 106 | { 107 | //*pc = (c1+c2) >> 1; 108 | *pc = Interpolate_2(c1, 1, c2, 1, 1); 109 | } 110 | 111 | static inline void Interp6(uint32_t * pc, uint32_t c1, uint32_t c2, uint32_t c3) 112 | { 113 | //*pc = (c1*5+c2*2+c3)/8; 114 | *pc = Interpolate_3(c1, 5, c2, 2, c3, 1, 3); 115 | } 116 | 117 | static inline void Interp7(uint32_t * pc, uint32_t c1, uint32_t c2, uint32_t c3) 118 | { 119 | //*pc = (c1*6+c2+c3)/8; 120 | *pc = Interpolate_3(c1, 6, c2, 1, c3, 1, 3); 121 | } 122 | 123 | static inline void Interp8(uint32_t * pc, uint32_t c1, uint32_t c2) 124 | { 125 | //*pc = (c1*5+c2*3)/8; 126 | *pc = Interpolate_2(c1, 5, c2, 3, 3); 127 | } 128 | 129 | static inline void Interp9(uint32_t * pc, uint32_t c1, uint32_t c2, uint32_t c3) 130 | { 131 | //*pc = (c1*2+(c2+c3)*3)/8; 132 | *pc = Interpolate_3(c1, 2, c2, 3, c3, 3, 3); 133 | } 134 | 135 | static inline void Interp10(uint32_t * pc, uint32_t c1, uint32_t c2, uint32_t c3) 136 | { 137 | //*pc = (c1*14+c2+c3)/16; 138 | *pc = Interpolate_3(c1, 14, c2, 1, c3, 1, 4); 139 | } 140 | 141 | #endif 142 | -------------------------------------------------------------------------------- /src/hq2x.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2003 Maxim Stepin ( maxst@hiend3d.com ) 3 | * 4 | * Copyright (C) 2010 Cameron Zemek ( grom@zeminvaders.net) 5 | * 6 | * This program is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 | */ 20 | 21 | #include 22 | #include "common.h" 23 | #include "hqx.h" 24 | 25 | #define PIXEL00_0 *dp = w[5]; 26 | #define PIXEL00_10 Interp1(dp, w[5], w[1]); 27 | #define PIXEL00_11 Interp1(dp, w[5], w[4]); 28 | #define PIXEL00_12 Interp1(dp, w[5], w[2]); 29 | #define PIXEL00_20 Interp2(dp, w[5], w[4], w[2]); 30 | #define PIXEL00_21 Interp2(dp, w[5], w[1], w[2]); 31 | #define PIXEL00_22 Interp2(dp, w[5], w[1], w[4]); 32 | #define PIXEL00_60 Interp6(dp, w[5], w[2], w[4]); 33 | #define PIXEL00_61 Interp6(dp, w[5], w[4], w[2]); 34 | #define PIXEL00_70 Interp7(dp, w[5], w[4], w[2]); 35 | #define PIXEL00_90 Interp9(dp, w[5], w[4], w[2]); 36 | #define PIXEL00_100 Interp10(dp, w[5], w[4], w[2]); 37 | #define PIXEL01_0 *(dp+1) = w[5]; 38 | #define PIXEL01_10 Interp1(dp+1, w[5], w[3]); 39 | #define PIXEL01_11 Interp1(dp+1, w[5], w[2]); 40 | #define PIXEL01_12 Interp1(dp+1, w[5], w[6]); 41 | #define PIXEL01_20 Interp2(dp+1, w[5], w[2], w[6]); 42 | #define PIXEL01_21 Interp2(dp+1, w[5], w[3], w[6]); 43 | #define PIXEL01_22 Interp2(dp+1, w[5], w[3], w[2]); 44 | #define PIXEL01_60 Interp6(dp+1, w[5], w[6], w[2]); 45 | #define PIXEL01_61 Interp6(dp+1, w[5], w[2], w[6]); 46 | #define PIXEL01_70 Interp7(dp+1, w[5], w[2], w[6]); 47 | #define PIXEL01_90 Interp9(dp+1, w[5], w[2], w[6]); 48 | #define PIXEL01_100 Interp10(dp+1, w[5], w[2], w[6]); 49 | #define PIXEL10_0 *(dp+dpL) = w[5]; 50 | #define PIXEL10_10 Interp1(dp+dpL, w[5], w[7]); 51 | #define PIXEL10_11 Interp1(dp+dpL, w[5], w[8]); 52 | #define PIXEL10_12 Interp1(dp+dpL, w[5], w[4]); 53 | #define PIXEL10_20 Interp2(dp+dpL, w[5], w[8], w[4]); 54 | #define PIXEL10_21 Interp2(dp+dpL, w[5], w[7], w[4]); 55 | #define PIXEL10_22 Interp2(dp+dpL, w[5], w[7], w[8]); 56 | #define PIXEL10_60 Interp6(dp+dpL, w[5], w[4], w[8]); 57 | #define PIXEL10_61 Interp6(dp+dpL, w[5], w[8], w[4]); 58 | #define PIXEL10_70 Interp7(dp+dpL, w[5], w[8], w[4]); 59 | #define PIXEL10_90 Interp9(dp+dpL, w[5], w[8], w[4]); 60 | #define PIXEL10_100 Interp10(dp+dpL, w[5], w[8], w[4]); 61 | #define PIXEL11_0 *(dp+dpL+1) = w[5]; 62 | #define PIXEL11_10 Interp1(dp+dpL+1, w[5], w[9]); 63 | #define PIXEL11_11 Interp1(dp+dpL+1, w[5], w[6]); 64 | #define PIXEL11_12 Interp1(dp+dpL+1, w[5], w[8]); 65 | #define PIXEL11_20 Interp2(dp+dpL+1, w[5], w[6], w[8]); 66 | #define PIXEL11_21 Interp2(dp+dpL+1, w[5], w[9], w[8]); 67 | #define PIXEL11_22 Interp2(dp+dpL+1, w[5], w[9], w[6]); 68 | #define PIXEL11_60 Interp6(dp+dpL+1, w[5], w[8], w[6]); 69 | #define PIXEL11_61 Interp6(dp+dpL+1, w[5], w[6], w[8]); 70 | #define PIXEL11_70 Interp7(dp+dpL+1, w[5], w[6], w[8]); 71 | #define PIXEL11_90 Interp9(dp+dpL+1, w[5], w[6], w[8]); 72 | #define PIXEL11_100 Interp10(dp+dpL+1, w[5], w[6], w[8]); 73 | 74 | HQX_API void HQX_CALLCONV hq2x_32_rb( uint32_t * sp, uint32_t srb, uint32_t * dp, uint32_t drb, int Xres, int Yres ) 75 | { 76 | int i, j, k; 77 | int prevline, nextline; 78 | uint32_t w[10]; 79 | int dpL = (drb >> 2); 80 | int spL = (srb >> 2); 81 | uint8_t *sRowP = (uint8_t *) sp; 82 | uint8_t *dRowP = (uint8_t *) dp; 83 | uint32_t yuv1, yuv2; 84 | 85 | // +----+----+----+ 86 | // | | | | 87 | // | w1 | w2 | w3 | 88 | // +----+----+----+ 89 | // | | | | 90 | // | w4 | w5 | w6 | 91 | // +----+----+----+ 92 | // | | | | 93 | // | w7 | w8 | w9 | 94 | // +----+----+----+ 95 | 96 | for (j=0; j0) prevline = -spL; else prevline = 0; 99 | if (j0) 108 | { 109 | w[1] = *(sp + prevline - 1); 110 | w[4] = *(sp - 1); 111 | w[7] = *(sp + nextline - 1); 112 | } 113 | else 114 | { 115 | w[1] = w[2]; 116 | w[4] = w[5]; 117 | w[7] = w[8]; 118 | } 119 | 120 | if (i 20 | #include 21 | #include 22 | #include 23 | #include 24 | 25 | #include "config.h" 26 | 27 | static inline uint32_t swapByteOrder(uint32_t ui) 28 | { 29 | return (ui >> 24) | ((ui << 8) & 0x00FF0000) | ((ui >> 8) & 0x0000FF00) | (ui << 24); 30 | } 31 | 32 | int main(int argc, char *argv[]) 33 | { 34 | int opt; 35 | int scaleBy = 4; 36 | while ((opt = getopt(argc, argv, "s:")) != -1) { 37 | switch (opt) { 38 | case 's': 39 | scaleBy = atoi(optarg); 40 | if (scaleBy != 2 && scaleBy != 3 && scaleBy != 4) { 41 | fprintf(stderr, "Only scale factors of 2, 3, and 4 are supported."); 42 | return 1; 43 | } 44 | break; 45 | default: 46 | goto error_usage; 47 | } 48 | } 49 | 50 | if (optind + 2 > argc) { 51 | error_usage: 52 | fprintf(stderr, "Usage: %s [-s scaleBy] input output\n", argv[0]); 53 | return 1; 54 | } 55 | 56 | ILuint handle, width, height; 57 | 58 | char *szFilenameIn = argv[optind]; 59 | char *szFilenameOut = argv[optind + 1]; 60 | 61 | ilInit(); 62 | ilEnable(IL_ORIGIN_SET); 63 | ilGenImages(1, &handle); 64 | ilBindImage(handle); 65 | 66 | // Load image 67 | ILboolean loaded = ilLoadImage(szFilenameIn); 68 | if (loaded == IL_FALSE) { 69 | fprintf(stderr, "ERROR: can't load '%s'\n", szFilenameIn); 70 | return 1; 71 | } 72 | width = ilGetInteger(IL_IMAGE_WIDTH); 73 | height = ilGetInteger(IL_IMAGE_HEIGHT); 74 | 75 | // Allocate memory for image data 76 | size_t srcSize = width * height * sizeof(uint32_t); 77 | uint8_t *srcData = (uint8_t *) malloc(srcSize); 78 | size_t destSize = width * scaleBy * height * scaleBy * sizeof(uint32_t); 79 | uint8_t *destData = (uint8_t *) malloc(destSize); 80 | 81 | // Init srcData from loaded image 82 | // We want the pixels in BGRA format so that when converting to uint32_t 83 | // we get a RGB value due to little-endianness. 84 | ilCopyPixels(0, 0, 0, width, height, 1, IL_BGRA, IL_UNSIGNED_BYTE, srcData); 85 | 86 | uint32_t *sp = (uint32_t *) srcData; 87 | uint32_t *dp = (uint32_t *) destData; 88 | 89 | // If big endian we have to swap the byte order to get RGB values 90 | #ifdef WORDS_BIGENDIAN 91 | uint32_t *spTemp = sp; 92 | for (i = 0; i < srcSize >> 2; i++) { 93 | spTemp[i] = swapByteOrder(spTemp[i]); 94 | } 95 | #endif 96 | 97 | hqxInit(); 98 | switch (scaleBy) { 99 | case 2: 100 | hq2x_32(sp, dp, width, height); 101 | break; 102 | case 3: 103 | hq3x_32(sp, dp, width, height); 104 | break; 105 | case 4: 106 | default: 107 | hq4x_32(sp, dp, width, height); 108 | break; 109 | } 110 | 111 | // If big endian we have to swap byte order of destData to get BGRA format 112 | #ifdef WORDS_BIGENDIAN 113 | uint32_t *dpTemp = dp; 114 | for (i = 0; i < destSize >> 2; i++) { 115 | dpTemp[i] = swapByteOrder(dpTemp[i]); 116 | } 117 | #endif 118 | 119 | // Copy destData into image 120 | ilTexImage(width * scaleBy, height * scaleBy, 0, 4, IL_BGRA, IL_UNSIGNED_BYTE, destData); 121 | 122 | // Free image data 123 | free(srcData); 124 | free(destData); 125 | 126 | // Save image 127 | ilConvertImage(IL_BGRA, IL_UNSIGNED_BYTE); // No alpha channel 128 | ilHint(IL_COMPRESSION_HINT, IL_USE_COMPRESSION); 129 | ilEnable(IL_FILE_OVERWRITE); 130 | ILboolean saved = ilSaveImage(szFilenameOut); 131 | 132 | ilDeleteImages(1, &handle); 133 | 134 | if (saved == IL_FALSE) { 135 | fprintf(stderr, "ERROR: can't save '%s'\n", szFilenameOut); 136 | return 1; 137 | } 138 | 139 | return 0; 140 | } 141 | -------------------------------------------------------------------------------- /src/hqx.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2003 Maxim Stepin ( maxst@hiend3d.com ) 3 | * 4 | * Copyright (C) 2010 Cameron Zemek ( grom@zeminvaders.net) 5 | * 6 | * This program is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 | */ 20 | 21 | #ifndef __HQX_H_ 22 | #define __HQX_H_ 23 | 24 | #include 25 | 26 | #if defined( __GNUC__ ) 27 | #ifdef __MINGW32__ 28 | #define HQX_CALLCONV __stdcall 29 | #else 30 | #define HQX_CALLCONV 31 | #endif 32 | #else 33 | #define HQX_CALLCONV 34 | #endif 35 | 36 | #if defined(_WIN32) 37 | #ifdef DLL_EXPORT 38 | #define HQX_API __declspec(dllexport) 39 | #else 40 | #define HQX_API __declspec(dllimport) 41 | #endif 42 | #else 43 | #define HQX_API 44 | #endif 45 | 46 | HQX_API void HQX_CALLCONV hqxInit(void); 47 | HQX_API void HQX_CALLCONV hq2x_32( uint32_t * src, uint32_t * dest, int width, int height ); 48 | HQX_API void HQX_CALLCONV hq3x_32( uint32_t * src, uint32_t * dest, int width, int height ); 49 | HQX_API void HQX_CALLCONV hq4x_32( uint32_t * src, uint32_t * dest, int width, int height ); 50 | 51 | HQX_API void HQX_CALLCONV hq2x_32_rb( uint32_t * src, uint32_t src_rowBytes, uint32_t * dest, uint32_t dest_rowBytes, int width, int height ); 52 | HQX_API void HQX_CALLCONV hq3x_32_rb( uint32_t * src, uint32_t src_rowBytes, uint32_t * dest, uint32_t dest_rowBytes, int width, int height ); 53 | HQX_API void HQX_CALLCONV hq4x_32_rb( uint32_t * src, uint32_t src_rowBytes, uint32_t * dest, uint32_t dest_rowBytes, int width, int height ); 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /src/init.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 Cameron Zemek ( grom@zeminvaders.net) 3 | * 4 | * This program is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 | */ 18 | 19 | #include 20 | #include "hqx.h" 21 | 22 | uint32_t RGBtoYUV[16777216]; 23 | uint32_t YUV1, YUV2; 24 | 25 | HQX_API void HQX_CALLCONV hqxInit(void) 26 | { 27 | /* Initalize RGB to YUV lookup table */ 28 | uint32_t c, r, g, b, y, u, v; 29 | for (c = 0; c < 16777215; c++) { 30 | r = (c & 0xFF0000) >> 16; 31 | g = (c & 0x00FF00) >> 8; 32 | b = c & 0x0000FF; 33 | y = (uint32_t)(0.299*r + 0.587*g + 0.114*b); 34 | u = (uint32_t)(-0.169*r - 0.331*g + 0.5*b) + 128; 35 | v = (uint32_t)(0.5*r - 0.419*g - 0.081*b) + 128; 36 | RGBtoYUV[c] = (y << 16) + (u << 8) + v; 37 | } 38 | } 39 | --------------------------------------------------------------------------------