xcalib-0.8.dfsg1/0000755000175000017500000000000010665533360013113 5ustar bencerbencerxcalib-0.8.dfsg1/README0000644000175000017500000003757210665523412014006 0ustar bencerbencerxcalib 0.8 ==================================================== (c) 2004-2007 Stefan Dhla This program is GPL-licensed postcardware! More infos at end of README. """"""""""""" This program comes with ABSOLUTELY NO WARRANTY! Use on your own risk. purpose: -------- load 'vcgt'-tag of ICC profiles to X-server like MS-Windows or MacOS do it to calibrate your display. Versions 0.5 and higher are also usable with Microsoft Windows. They can be used as a free alternative to other calibration loaders. usage: ------ xcalib [-options] ICCPROFILE or xcalib [-options] -alter where the available options are: -display or -d -screen or -s -clear or -c -noaction or -n -verbose or -v -printramps or -p -loss or -l -invert or -i -gammacor or -gc -brightness or -b -contrast or -co -red -green -blue -alter or -a -help or -h -version last parameter MUST be an ICC profile containing a vcgt or mLUT tag or empty if the "-a" or "-alter" paramter is used or the LUT is to be cleared. use profiles gamma_1_0.icc and gamma_2_2.icc for testing. Profiles with vcg-tables can be created with most profile creation suites. An example profile with a vcg-table is inclued, named bluish.icc, which simulates a very high whitepoint (without further intentions). !Special note for Win32 users: If there is a default profile set for the primary display, running xcalib.exe without any arguments will use the Windows default profile. If the profile contains gamma values, these values may be related to a special global gamma value. The default internal correction value is 1.0, as Apple does (the creator of these calibration tags in ICC profiles). To resemble the behaviour of the Windows XP Color Control Panel, pass "-gammacor 2.2" if you think, the screen is way to bright. The values that shouldn't alter the screen for gamma, brightness and contrast are gamma=1.0 brightness=0.0 and contrast=100.0 . requirements: ------------- LINUX/UNIXes: This program is intended for X11-Servers like XFree86 that come with XVidModeExtension (e.g. XFree86 4.x.x). Make sure that the extension is available. Other X-servers like OpenWin do not contain XVidMode stuff - so please don't ask me for support if XVidMode isn't supported. If you are experiencing problems with the X.org server because of missing XVidMode header files, search for the additional packages that are available for most distributions. Debian provides the headers by the package libxxf86vm-dev package. As of version 0.6, a special treatment for the close-source ATI FGLRX X11 driver was added. The libs and header files are provided but may need to be updated for the most current video cards. The X11 and XVidMode headers are still required. Thanks to bleader who sent me a patch for multi-monitor support Microsoft Windows: Since version 0.5, Win32-support was added. The program will work with most video cards, that have correctly implemented drivers. You need a working C compiler with the right windows headers to rebuild xcalib. Thanks to gl.tter multi-monitor support for Win32 is now available. testing: -------- You need a profile which contains the 'vcgt' tag to achieve monitor calibration. You can create it with some commercial windows profile creation programs or use the bundled ones from Bruce Lindbloom (only Gamma 1.0 and 2.2). If you prefer using free (as the free in open-source) profile creation programs, have a look at current versions of ArgyllCMS. It was mentioned that LProf is now also capable of creating monitor profiles with vcgt tags included. install: -------- The bundled Makefile should work on most systems. It is very simple and doesn't use automake/autoconf stuff. Therefore you and I (the author) save time writing fancy autoconf/automake tests. One of the following commands should lead you to a working version of xcalib: $ make xcalib $ make win_xcalib $ make fglrx_xcalib For most UNIX-based systems the default version of xcalib should work. It only uses the XVidMode-Extension. The following command creates the executable: $ make xcalib The Win32 version was made with and tested for MinGW. Since most users do not have a running MinGW environment, a binary executable is provided. To compile it on your own, the following command creates a working Win32-build (tested with MSys): $ make win_xcalib For ATI's proprietary FGLRX driver for X11, a special version can be built. Issue the command $ make fglrx_xcalib motivation: ----------- ICC profiles created and used with MS-Windows can now also be used with Linux and other unixes with LCMS, Marti's ICC library. Some applications can already apply profiles (even display profiles) but they often use standard monitor profiles or custom profiles created for a calibrated monitor. Calibration is the motivation for xcalib. Calibration brings your monitor to a defined state. Color spaces of profiles are often only valid for this defined state, which was created by a calibration. Whenever you use a display profile, created with Gretag's ProfileMaker, AdobeGamma (not that good but better than nothing) or most other ICC profile creation packages, 'vcgt'-tags are included. These profiles are only valid with calibration applied! You get the point? Once again, a profile contains mainly the characterization of a device. This characterization should be constant over time for as long as possible. Therefore, you need a defined state, you can return to - this is the calibrated state. Calibration linearizes your device, helps to set characteristics and can be easily repeated. Repeating calibration can help you to keep your profile constant (users don't need to change it). The current way of embedding calibration data in a profile is against the theory of separating calibration from profiling - but we have to live with it since it's common. They use a tag called Video Card Gamma Tag (or vcgt) in ICC-profiles that contains calibration values. The calibration is applied before profile creation, where the vcgt will be saved in your profile for convenience reasons: All color settings for the display device are stored in a common file. So, let's repeat: We have calibration and profile creation - which are not the same. But calibration helps the user in the profile creation by having a linear (or linear with respect to a fixed gamma value) display device. Linux was missing a tool like 'AdobeGammaLoader' or 'Logo Calibration Loader' which applied the vcgt-tag to the video-LUT (a matrix which assigns one color value to another). Under Linux we can not set the video-LUT itself but a X-server gamma ramp (which does practically the same). Applying gamma ramps in the video-LUT has one big advantage: If used with proper values, all applications benefit from a monitor in a defined/calibrated state - although not using color management! But keep the drawback in mind: You will loose some resolution by using a tool like AdobeGamme oder xcalib. This may leed to posterization artifacts on your display (but doesn't affect printouts). You should tweak your monitor for perfect linearization as much as possible - the remaining tweaks might be part of a profile (, the "vcgt" tag). If you want to come around that drawback: bug your video card vendor and ask for >8bit LUTs (plus LUTs for every output connector). limitations: ------------ Not all XFree video card drivers do allow changing the gamma ramps. And video cards are often having only one LUT for all outputs - although they are dual-head models. Known not-working drivers: - vesa (generic driver without any calibration knobs) - fglrx (but you can build fglrx_xcalib) - savage with other depths than 24 (known bug in savage driver) => solution: change DefaultDepth to 24 in xorg.conf if you have enough video memory (may not work together with 3D). If you see both/only one/no display changing it's behaviour, test if it's a bug of xcalib by cross-checking with the 'xgamma' tool that comes with every XFree86/X.org distribution. Recently, OpenGL-accelerated window managers became a new fashion. There have been reports that xcalib and similar tools do not work there. Resolving this issue is on the TODO-list but may require new X11 core components. Custom curves created with AdobeGamma do not contain these in the vcgt. The vcgt contains 2.2 in all cases, whereas the real LUT-values that are downloaded to the X-server are located somewhere else in the system - but nobody know's where. Please tell me where they are - if you find them. A newer version of AdobeGamma (from 2003) writes a vcgt tag with useful data. Nevertheless, the size field is wrong. As of version 0.6, a work-around for wrong AdobeGamma profiles (created with the 2003 version) was added to the internal parser. On Win32-systems, some drivers are not correctly implemented. E.g. the NVidia Riva driver for Windows2000 and WindowsXP wrote nonsense values to the video cards RAMDAC (resulting in a gray display). I used for these cards an old NT-driver from a video card vendor. The source code became messy in the last time because of numerous workarounds and a bad mixture of Win32, X11, ATI code and code for the different parsers used to get the gamma ramps from the profile. This makes it hard to find the important code sections for others than me and might have lead to bugs or leaks. A following version may be written in C++ to ease modularisation of the code and allow utilization by other software. history: -------- 0.8: 2007-08-27 - applied gl.tter's patch for Win32 multi-monitor support - applied bleader's patch for FGLRX multi-monitor support - added support for LUTs bigger than in the profile linear interpolation is used for creating the values in between - changed -n parameter: now the size of the simulated LUT must be given after -n/-noaction paramter 0.7: 2007-06-23 - major code-cleanup - fixed gamma limits for vcg-formulae thanks to Graeme Gill, who pointed out the mistake - implemented user-changeable gamma correction - added alteration of existing LUTs - added parameters for addiditional brightness, contrast, gamma either globally or per color - removed icclib for parsing ICC profiles - removed the LCMS patch since it doesn't work with newer versions - check string sizes before strcpy now - fixed Win32 ICM profile fetching - added inversion of all values: not related to color-management but funny feature for the weekends - updated this README 0.6: 2005-09-30 - added 0-interpolated upscaling if LUT>vcgt - added reading of mLUT instead of vcgt (not memory-safe for now) this is used for profiles, created by ProfileMechanic Monitor - added parsing of obviously wrong profiles made by AdobeGamma - added fglrx version for ATI's proprietary driver - added loss calculation (option "-loss" or "-l") which shows how many steps are lost by calibrating the device - added limits of VideoCardGammaFormula to internal parser 0.5: 2005-03-03 - Win32 version added (compilable with MinGW) + support for command line options as usual + support for loading the default display profile - fixed bug with 8bit vcg-tables in internal and icclib version this applied to Pantone ColorVision Spyder profiles only thanks to John Ackerman who found this really grave bug - fixed bug in lcms patch regarding gamma table endpoints use a unpatched version of lcms for patching - introduced macro for little-endian parsing in internal parser - got rid of some compiler warnings because of multi-byte constants - introduced variables in Makefile so that the user can set locations for X11 and patched lcms libs and headers - beautified code for better readability - added sample profile which contains a vcg-table 0.4: 2005-01-30 - own implementation for parsing the vcgt tags added. - switch to lcms-1.13 (patched) instead of icclib use different make target to activate it - LUTs and vcgt-content may now have different size. LCMS does scaling for xcalib this only works with a LCMS build for now - much icc- and vcgt-stuff was exported to LCMS, to give every user the ability to use it and to make xcalib's code less confuscating apply the bundled patch to LCMS - minor README changes to ease readability 0.3: - raise error if no vcg-tag available - profile no more a necessary parameter after -c and -h option - some code cleanup 0.2: public pre-release - added option to reset gamma table to system default (gamma 1.0) - screen and display can be selected now - as system gamma for Linux, 1/0.45 = 2.222 is assumed - bugfixes 0.1: - initial version with vcg-table and vcg-formula working todo: ----- [ ] integrate the _ICC_PROFILE atom [X] interpolated upscaling [X] use ATI's API when using the closed-source X11 ATI driver [X] further code review for memory leaks [x] use platform independent types for better portability [X] use lcms instead of icclib: worse vcgt-parsing but functions for gamma ramp building and smoothing [X] add multi-monitor support to Win32 version [X] apply bleader's patch for multiple FGLRX cards bugs: ----- if not already mentioned in this README, contact the author if you find bugs in this software. author: -------- Stefan Dhla thanks: ------- Graeme Gill for his icclib which I used to parse ICC profiles in versions prior 0.4 and which contained vcgt-parsing source code. Note that he has a similar tool now, called dispwin. Because both tools are similar, he found some ambiguity in the case of gamma values and limits in vcgt tags. Thanks, Graeme, keep up the good work! Kai-Uwe Behrmann for his ideas and alpha-testing Note that Kai-Uwe uses xcalib in his Oyranos package RRZE (Regionales Rechenzentrum Erlangen) which employed me to ensure constant color quality for their large-format-printers and led me to color-management using ICC profiles My current employer for giving me the bucks I need to buy everyday-stuff and bringing happiness to my life The X11-team for implementing the gamma ramps (but they weren't used!?) Gretag/Logosoft for their ProfileMaker software which my former employer bought - and MonitorCalibrationTester, to debug vcgt-stuff on Win32 Marti Maria and his lcms-community which led me to the vision of having xcalib Marti especially for LCMS: his lib for color-management Bruce Lindbloom for his ICC-profiles using vcg-formulae gl.tter for his work on multi-monitor support for Win32 see his website at http://gl.tter.org bleader for his work on multi-monitor support for ATI's FGLRX links: ------ The following links might lead you to other Linux color management ressources: http://www.littlecms.com http://www.argyllcms.com http://www.coloraid.de http://www.behrmann.name http://lprof.sourceforge.net license: -------- You should have received a copy of the GPL together with this software. Furthermore, it is postcardware. So if you like this program, send me a picture postcard from your country/area to: Stefan Doehla Steinselb 7 95100 Selb GERMANY Please write on it your name and email-address and that you use xcalib-0.8 . EOF xcalib-0.8.dfsg1/COPYING0000644000175000017500000003605610665523412014155 0ustar bencerbencerThis program is proteced by the GPL as following. This program is furthermore postcard-ware which means, that if you do really use this program, consider sending a postcard from your country to the author. The author likes postcards! See README for address info. GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 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. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, 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 or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's 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 give any other recipients of the Program a copy of this License along with the Program. 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 Program or any portion of it, thus forming a work based on the Program, 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) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, 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 Program, 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 Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) 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; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, 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 executable. However, as a special exception, the source code 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. If distribution of executable or 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 counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program 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. 5. 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 Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program 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 to this License. 7. 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 Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program 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 Program. 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. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program 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. 9. The Free Software Foundation may publish revised and/or new versions of the 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 Program 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 Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, 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 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "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 PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. 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 PROGRAM 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 PROGRAM (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 PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS xcalib-0.8.dfsg1/README.profilers0000644000175000017500000000142610665523412015777 0ustar bencerbencerThis document tries to compare the calibration data embedded in ICC profiles created with different display profilers. Pantone Colorvision Spyder: --------------------------- vcgt, table with 256 * 8bit entries BasiCColor display: ------------------- vcgt, table with 256 * 16bit entries Gretag/Logo ProfileMaker 4.1: ------------------------ vcgt, table with 256 * 16bit entries lprof, Marti's little profiler (unmaintained): ---------------------------------------------- no calibration Profile Mechanic Monitor (by Jonathan Sachs) -------------------------------------------- mLUT, table with 256 * 16bit entries AdobeGamma (came with Photoshop CS) ----------------------------------- vcgt, table with 256 * 16bit entries, signalled as 8bit entries! (c) 2005 - Stefan Doehla EOF xcalib-0.8.dfsg1/Makefile0000644000175000017500000000436710665523412014562 0ustar bencerbencer# Makefile for xcalib # # (c) 2004-2007 Stefan Doehla # # This program is GPL-ed postcardware! please see README # # It is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program 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 # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, # MA 02111-1307 USA. # # # the following targets are defined: # - xcalib # default # - win_xcalib # version for MS-Windows systems with MinGW (internal parser) # - fglrx_xcalib # version for ATI's proprietary fglrx driver (internal parser) # # - clean # delete all objects and binaries # # if it doesn't compile right-out-of-the-box, it may be sufficient # to change the following variables XCALIB_VERSION = 0.8 CFLAGS = -O2 XINCLUDEDIR = /usr/X11R6/include XLIBDIR = /usr/X11R6/lib # for ATI's proprietary driver (must contain the header file fglrx_gamma.h) FGLRXINCLUDEDIR = ./fglrx FGLRXLIBDIR = ./fglrx # default make target all: xcalib # low overhead version (internal parser) xcalib: xcalib.c $(CC) $(CFLAGS) -c xcalib.c -I$(XINCLUDEDIR) -DXCALIB_VERSION=\"$(XCALIB_VERSION)\" $(CC) $(CFLAGS) -L$(XLIBDIR) -lm -o xcalib xcalib.o -lX11 -lXxf86vm -lXext fglrx_xcalib: xcalib.c $(CC) $(CFLAGS) -c xcalib.c -I$(XINCLUDEDIR) -DXCALIB_VERSION=\"$(XCALIB_VERSION)\" -I$(FGLRXINCLUDEDIR) -DFGLRX $(CC) $(CFLAGS) -L$(XLIBDIR) -L$(FGLRXLIBDIR) -lm -o xcalib xcalib.o -lX11 -lXxf86vm -lXext -lfglrx_gamma win_xcalib: xcalib.c $(CC) $(CFLAGS) -c xcalib.c -DXCALIB_VERSION=\"$(XCALIB_VERSION)\" -DWIN32GDI windres.exe resource.rc resource.o $(CC) $(CFLAGS) -mwindows -lm resource.o -o xcalib xcalib.o install: cp ./xcalib $(DESTDIR)/usr/local/bin/ chmod 0644 $(DESTDIR)/usr/local/bin/xcalib clean: rm -f xcalib.o rm -f resource.o rm -f xcalib rm -f xcalib.exe xcalib-0.8.dfsg1/icon.ico0000644000175000017500000000706610665523412014545 0ustar bencerbencer &h( @55Ogg R :: R $ h h $ U@@U+jj+XEEX1ll1&[&&&ـ&JJ&&&٤&[&&8&m&&m&8&/`///Ѐ/OO///П/`//?/p//p/?/7c77ȹ7Ȁ7TT777Ȝ7c77F7q77q7F7 * * This program is GPL-ed postcardware! please see README * * It is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program 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 * General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, * MA 02111-1307 USA. */ /* * xcalib is a tiny tool to load the content of vcgt-Tags in ICC * profiles to the video card's gamma ramp. It does work with most * video card drivers except the generic VESA driver. * * There are three ways to parse an ICC profile: * - use Graeme Gill's icclib (bundled) * - use a patched version of Marti Maria's LCMS (patches included) * - use internal parsing routines for vcgt-parsing only * * Using icclib is known to work best, patched LCMS has the * advantage of gamma ramp interpolation and the internal routine * is perfect for low overhead versions of xcalib. */ /* vim: set ai ts=2 sw=2 expandtab: */ #include #include #include #include #include #include #include #include /* for X11 VidMode stuff */ #ifndef WIN32GDI # include # include # include # include # ifdef FGLRX # include # endif #else # include # include #endif #include /* the 4-byte marker for the vcgt-Tag */ #define VCGT_TAG 0x76636774L #define MLUT_TAG 0x6d4c5554L #ifndef XCALIB_VERSION # define XCALIB_VERSION "version unknown (>0.5)" #endif /* a limit to check the table sizes (of corrupted profiles) */ #ifndef MAX_TABLE_SIZE # define MAX_TABLE_SIZE 2e10 #endif #ifdef WIN32GDI # define u_int16_t WORD #endif /* prototypes */ void error (char *fmt, ...), warning (char *fmt, ...), message(char *fmt, ...); #if 1 # define BE_INT(a) ((a)[3]+((a)[2]<<8)+((a)[1]<<16) +((a)[0]<<24)) # define BE_SHORT(a) ((a)[1]+((a)[0]<<8)) #else # warning "big endian is NOT TESTED" # define BE_INT(a) (a) # define BE_SHORT(a) (a) #endif /* internal state struct */ struct xcalib_state_t { unsigned int verbose; float redGamma; float redMin; float redMax; float greenGamma; float greenMin; float greenMax; float blueGamma; float blueMin; float blueMax; float gamma_cor; } xcalib_state = {0, 1.0, 0.0, 1.0, 1.0, 0.0, 1.0, 1.0, 0.0, 1.0, 1.0}; void usage (void) { fprintf (stdout, "xcalib %s\n", XCALIB_VERSION); fprintf (stdout, "Copyright (C) 2004-2007 Stefan Doehla \n"); fprintf (stdout, "THIS PROGRAM COMES WITH ABSOLUTELY NO WARRANTY!\n"); fprintf (stdout, "\n"); fprintf (stdout, "usage: xcalib [-options] ICCPROFILE\n"); fprintf (stdout, " or xcalib [-options] -alter\n"); fprintf (stdout, "\n"); fprintf (stdout, "where the available options are:\n"); #ifndef WIN32GDI fprintf (stdout, " -display or -d\n"); fprintf (stdout, " -screen or -s\n"); #else fprintf (stdout, " -screen or -s\n"); #endif #ifdef FGLRX fprintf (stdout, " -controller or -x\n"); #endif fprintf (stdout, " -clear or -c\n"); fprintf (stdout, " -noaction or -n\n"); fprintf (stdout, " -verbose or -v\n"); fprintf (stdout, " -printramps or -p\n"); fprintf (stdout, " -loss or -l\n"); fprintf (stdout, " -invert or -i\n"); fprintf (stdout, " -gammacor or -gc\n"); fprintf (stdout, " -brightness or -b\n"); fprintf (stdout, " -contrast or -co\n"); fprintf (stdout, " -red \n"); fprintf (stdout, " -green \n"); fprintf (stdout, " -blue \n"); #ifndef FGLRX fprintf (stdout, " -alter or -a\n"); #endif fprintf (stdout, " -help or -h\n"); fprintf (stdout, " -version\n"); fprintf (stdout, "\n"); fprintf (stdout, "last parameter must be an ICC profile containing a vcgt-tag\n"); fprintf (stdout, "\n"); #ifndef WIN32GDI fprintf (stdout, "Example: ./xcalib -d :0 -s 0 -v bluish.icc\n"); #else fprintf (stdout, "Example: ./xcalib -v bluish.icc\n"); #endif #ifndef FGLRX fprintf (stdout, "Example: ./xcalib -red 1.1 10.0 100.0\n"); #endif fprintf (stdout, "\n"); exit (0); } #ifdef WIN32GDI /* Win32 monitor enumeration - code by gl.tter ( http://gl.tter.org ) */ static unsigned int monitorSearchIndex = 0; static HDC monitorDC = 0; /* * FUNCTION MonitorEnumProc * * this is a Win32 callback function which is given as an argument * to EnumDisplayMonitors. * * returns * TRUE: if the current enumerated display is the wrong one * FALSE: if the right monitor was found and the DC was associated */ BOOL CALLBACK MonitorEnumProc (HMONITOR monitor, HDC hdc, LPRECT rect, LPARAM data) { MONITORINFOEX monitorInfo; if(monitorSearchIndex++ != (unsigned int)data) return TRUE; /* continue enumeration */ monitorInfo.cbSize = sizeof(monitorInfo); if(GetMonitorInfo(monitor, (LPMONITORINFO)&monitorInfo) ) monitorDC = CreateDC(NULL, monitorInfo.szDevice, NULL, NULL); return FALSE; /* stop enumeration */ } /* * FUNCTION FindMonitor * * find a specific monitor given by index. Index -1 is the * primary display. * * returns the DC of the selected monitor */ HDC FindMonitor(int index) { if(index == -1) return GetDC(NULL); /* return primary display context */ monitorSearchIndex = 0; monitorDC = 0; EnumDisplayMonitors(NULL, NULL, MonitorEnumProc, index); return monitorDC; } #endif /* * FUNCTION read_vcgt_internal * * this is a parser for the vcgt tag of ICC profiles which tries to * resemble most of the functionality of Graeme Gill's icclib. * * returns * -1: file could not be read * 0: file okay but doesn't contain vcgt or MLUT tag * 1: success */ int read_vcgt_internal(const char * filename, u_int16_t * rRamp, u_int16_t * gRamp, u_int16_t * bRamp, unsigned int nEntries) { FILE * fp; unsigned int bytesRead; unsigned int numTags=0; unsigned int tagName=0; unsigned int tagOffset=0; unsigned int tagSize=0; unsigned char cTmp[4]; unsigned int uTmp; unsigned int gammaType; signed int retVal=0; u_int16_t * redRamp = NULL, * greenRamp = NULL, * blueRamp = NULL; unsigned int ratio=0; /* formula */ float rGamma, rMin, rMax; float gGamma, gMin, gMax; float bGamma, bMin, bMax; int i=0; /* table */ unsigned int numChannels=0; unsigned int numEntries=0; unsigned int entrySize=0; int j=0; if(filename) { fp = fopen(filename, "rb"); if(!fp) return -1; /* file can not be opened */ } else return -1; /* filename char pointer not valid */ /* skip header */ if(fseek(fp, 0+128, SEEK_SET)) return -1; /* check num of tags in current profile */ bytesRead = fread(cTmp, 1, 4, fp); numTags = BE_INT(cTmp); for(i=0; i 5.0 || gGamma > 5.0 || bGamma > 5.0) { warning("Gamma values out of range (> 5.0): \nR: %f \tG: %f \t B: %f", rGamma, gGamma, bGamma); break; } if(rMin >= 1.0 || gMin >= 1.0 || bMin >= 1.0) { warning("Gamma lower limit out of range (>= 1.0): \nRMin: %f \tGMin: %f \t BMin: %f", rMin, gMin, bMin); break; } if(rMax > 1.0 || gMax > 1.0 || bMax > 1.0) { warning("Gamma upper limit out of range (> 1.0): \nRMax: %f \tGMax: %f \t BMax: %f", rMax, gMax, bMax); break; } message("Red: Gamma %f \tMin %f \tMax %f\n", rGamma, rMin, rMax); message("Green: Gamma %f \tMin %f \tMax %f\n", gGamma, gMin, gMax); message("Blue: Gamma %f \tMin %f \tMax %f\n", bGamma, bMin, bMax); for(j=0; j= nEntries) { /* simply subsample if the LUT is smaller than the number of entries in the file */ ratio = (unsigned int)(numEntries / (nEntries)); for(j=0; j= argc) usage (); displayname = argv[i]; continue; } #endif /* X11 screen / Win32 monitor index */ if (!strcmp (argv[i], "-s") || !strcmp (argv[i], "-screen")) { if (++i >= argc) usage (); screen = atoi (argv[i]); continue; } #ifdef FGLRX /* ATI controller index (for FGLRX only) */ if (!strcmp (argv[i], "-x") || !strcmp (argv[i], "-controller")) { if (++i >= argc) usage (); controller = atoi (argv[i]); continue; } #endif /* print ramps to stdout */ if (!strcmp (argv[i], "-p") || !strcmp (argv[i], "-printramps")) { printramps = 1; continue; } /* print error introduced by applying ramps to stdout */ if (!strcmp (argv[i], "-l") || !strcmp (argv[i], "-loss")) { calcloss = 1; continue; } /* invert the LUT */ if (!strcmp (argv[i], "-i") || !strcmp (argv[i], "-invert")) { invert = 1; continue; } /* clear gamma lut */ if (!strcmp (argv[i], "-c") || !strcmp (argv[i], "-clear")) { clear = 1; continue; } #ifndef FGLRX /* alter existing lut */ if (!strcmp (argv[i], "-a") || !strcmp (argv[i], "-alter")) { alter = 1; continue; } #endif /* do not alter video-LUTs : work's best in conjunction with -v! */ if (!strcmp (argv[i], "-n") || !strcmp (argv[i], "-noaction")) { donothing = 1; if (++i >= argc) usage(); ramp_size = atoi(argv[i]); continue; } /* global gamma correction value (use 2.2 for WinXP Color Control-like behaviour) */ if (!strcmp (argv[i], "-gc") || !strcmp (argv[i], "-gammacor")) { if (++i >= argc) usage(); xcalib_state.gamma_cor = atof (argv[i]); correction = 1; continue; } /* take additional brightness into account */ if (!strcmp (argv[i], "-b") || !strcmp (argv[i], "-brightness")) { double brightness = 0.0; if (++i >= argc) usage(); brightness = atof(argv[i]); if(brightness < 0.0 || brightness > 99.0) { warning("brightness is out of range 0.0-99.0"); continue; } xcalib_state.redMin = xcalib_state.greenMin = xcalib_state.blueMin = brightness / 100.0; xcalib_state.redMax = xcalib_state.greenMax = xcalib_state.blueMax = (1.0 - xcalib_state.blueMin) * xcalib_state.blueMax + xcalib_state.blueMin; correction = 1; continue; } /* take additional contrast into account */ if (!strcmp (argv[i], "-co") || !strcmp (argv[i], "-contrast")) { double contrast = 100.0; if (++i >= argc) usage(); contrast = atof(argv[i]); if(contrast < 1.0 || contrast > 100.0) { warning("contrast is out of range 1.0-100.0"); continue; } xcalib_state.redMax = xcalib_state.greenMax = xcalib_state.blueMax = contrast / 100.0; xcalib_state.redMax = xcalib_state.greenMax = xcalib_state.blueMax = (1.0 - xcalib_state.blueMin) * xcalib_state.blueMax + xcalib_state.blueMin; correction = 1; continue; } /* additional red calibration */ if (!strcmp (argv[i], "-red")) { double gamma = 1.0, brightness = 0.0, contrast = 100.0; if (++i >= argc) usage(); gamma = atof(argv[i]); if(gamma < 0.1 || gamma > 5.0) { warning("gamma is out of range 0.1-5.0"); continue; } if (++i >= argc) usage(); brightness = atof(argv[i]); if(brightness < 0.0 || brightness > 99.0) { warning("brightness is out of range 0.0-99.0"); continue; } if (++i >= argc) usage(); contrast = atof(argv[i]); if(contrast < 1.0 || contrast > 100.0) { warning("contrast is out of range 1.0-100.0"); continue; } xcalib_state.redMin = brightness / 100.0; xcalib_state.redMax = (1.0 - xcalib_state.redMin) * (contrast / 100.0) + xcalib_state.redMin; xcalib_state.redGamma = gamma; correction = 1; continue; } /* additional green calibration */ if (!strcmp (argv[i], "-green")) { double gamma = 1.0, brightness = 0.0, contrast = 100.0; if (++i >= argc) usage(); gamma = atof(argv[i]); if(gamma < 0.1 || gamma > 5.0) { warning("gamma is out of range 0.1-5.0"); continue; } if (++i >= argc) usage(); brightness = atof(argv[i]); if(brightness < 0.0 || brightness > 99.0) { warning("brightness is out of range 0.0-99.0"); continue; } if (++i >= argc) usage(); contrast = atof(argv[i]); if(contrast < 1.0 || contrast > 100.0) { warning("contrast is out of range 1.0-100.0"); continue; } xcalib_state.greenMin = brightness / 100.0; xcalib_state.greenMax = (1.0 - xcalib_state.greenMin) * (contrast / 100.0) + xcalib_state.greenMin; xcalib_state.greenGamma = gamma; correction = 1; continue; } /* additional blue calibration */ if (!strcmp (argv[i], "-blue")) { double gamma = 1.0, brightness = 0.0, contrast = 100.0; if (++i >= argc) usage(); gamma = atof(argv[i]); if(gamma < 0.1 || gamma > 5.0) { warning("gamma is out of range 0.1-5.0"); continue; } if (++i >= argc) usage(); brightness = atof(argv[i]); if(brightness < 0.0 || brightness > 99.0) { warning("brightness is out of range 0.0-99.0"); continue; } if (++i >= argc) usage(); contrast = atof(argv[i]); if(contrast < 1.0 || contrast > 100.0) { warning("contrast is out of range 1.0-100.0"); continue; } xcalib_state.blueMin = brightness / 100.0; xcalib_state.blueMax = (1.0 - xcalib_state.blueMin) * (contrast / 100.0) + xcalib_state.blueMin; xcalib_state.blueGamma = gamma; correction = 1; continue; } if (i != argc - 1 && !clear && i) { usage (); } if(!clear || !alter) { if(strlen(argv[i]) < 255) strcpy (in_name, argv[i]); else usage (); } } #ifdef WIN32GDI if ((!clear || !alter) && (in_name[0] == '\0')) { hDc = FindMonitor(screen); win_profile_len = MAX_PATH; win_default_profile[0] = '\0'; SetICMMode(hDc, ICM_ON); if(GetICMProfileA(hDc, (LPDWORD) &win_profile_len, (LPSTR)win_default_profile)) { if(strlen(win_default_profile) < 255) strcpy (in_name, win_default_profile); else usage(); } else usage(); } #endif #ifndef WIN32GDI /* X11 initializing */ if ((dpy = XOpenDisplay (displayname)) == NULL) { if(!donothing) error ("Can't open display %s", XDisplayName (displayname)); else warning("Can't open display %s", XDisplayName (displayname)); } else if (screen == -1) screen = DefaultScreen (dpy); /* clean gamma table if option set */ gamma.red = 1.0; gamma.green = 1.0; gamma.blue = 1.0; if (clear) { #ifndef FGLRX if (!XF86VidModeSetGamma (dpy, screen, &gamma)) { #else for(i = 0; i < 256; i++) { fglrx_gammaramps.RGamma[i] = i << 2; fglrx_gammaramps.GGamma[i] = i << 2; fglrx_gammaramps.BGamma[i] = i << 2; } if (!FGLRX_X11SetGammaRamp_C16native_1024(dpy, screen, controller, 256, &fglrx_gammaramps)) { #endif XCloseDisplay (dpy); error ("Unable to reset display gamma"); } goto cleanupX; } /* get number of entries for gamma ramps */ if(!donothing) { #ifndef FGLRX if (!XF86VidModeGetGammaRampSize (dpy, screen, &ramp_size)) { #else if (!FGLRX_X11GetGammaRampSize(dpy, screen, &ramp_size)) { #endif XCloseDisplay (dpy); if(!donothing) error ("Unable to query gamma ramp size"); else { warning ("Unable to query gamma ramp size - assuming 256"); ramp_size = 256; } } } #else /* WIN32GDI */ if(!donothing) { if(!hDc) hDc = FindMonitor(screen); if (clear) { if (!SetDeviceGammaRamp(hDc, &winGammaRamp)) error ("Unable to reset display gamma"); goto cleanupX; } } #endif /* check for ramp size being a power of 2 and inside the supported range */ switch(ramp_size) { case 16: case 32: case 64: case 128: case 256: case 512: case 1024: case 2048: case 4096: case 8192: case 16384: case 32768: case 65536: break; default: error("unsupported ramp size %u", ramp_size); } r_ramp = (unsigned short *) malloc (ramp_size * sizeof (unsigned short)); g_ramp = (unsigned short *) malloc (ramp_size * sizeof (unsigned short)); b_ramp = (unsigned short *) malloc (ramp_size * sizeof (unsigned short)); if(!alter) { if( (i = read_vcgt_internal(in_name, r_ramp, g_ramp, b_ramp, ramp_size)) <= 0) { if(i<0) warning ("Unable to read file '%s'", in_name); if(i=0) warning ("No calibration data in ICC profile '%s' found", in_name); free(r_ramp); free(g_ramp); free(b_ramp); exit(0); } } else { #ifndef WIN32GDI if (!XF86VidModeGetGammaRamp (dpy, screen, ramp_size, r_ramp, g_ramp, b_ramp)) warning ("Unable to get display calibration"); #else if (!GetDeviceGammaRamp(hDc, &winGammaRamp)) warning ("Unable to get display calibration"); for (i = 0; i < ramp_size; i++) { r_ramp[i] = winGammaRamp.Red[i]; g_ramp[i] = winGammaRamp.Green[i]; b_ramp[i] = winGammaRamp.Blue[i]; } #endif } { float redBrightness = 0.0; float redContrast = 100.0; float redMin = 0.0; float redMax = 1.0; float redGamma = 1.0; redMin = (double)r_ramp[0] / 65535.0; redMax = (double)r_ramp[ramp_size - 1] / 65535.0; redBrightness = redMin * 100.0; redContrast = (redMax - redMin) / (1.0 - redMin) * 100.0; message("Red Brightness: %f Contrast: %f Max: %f Min: %f\n", redBrightness, redContrast, redMax, redMin); } { float greenBrightness = 0.0; float greenContrast = 100.0; float greenMin = 0.0; float greenMax = 1.0; float greenGamma = 1.0; greenMin = (double)g_ramp[0] / 65535.0; greenMax = (double)g_ramp[ramp_size - 1] / 65535.0; greenBrightness = greenMin * 100.0; greenContrast = (greenMax - greenMin) / (1.0 - greenMin) * 100.0; message("Green Brightness: %f Contrast: %f Max: %f Min: %f\n", greenBrightness, greenContrast, greenMax, greenMin); } { float blueBrightness = 0.0; float blueContrast = 100.0; float blueMin = 0.0; float blueMax = 1.0; float blueGamma = 1.0; blueMin = (double)b_ramp[0] / 65535.0; blueMax = (double)b_ramp[ramp_size - 1] / 65535.0; blueBrightness = blueMin * 100.0; blueContrast = (blueMax - blueMin) / (1.0 - blueMin) * 100.0; message("Blue Brightness: %f Contrast: %f Max: %f Min: %f\n", blueBrightness, blueContrast, blueMax, blueMin); } if(correction != 0) { for(i=0; i= ramp_size / 2) break; tmpRampVal = r_ramp[i]; r_ramp[i] = r_ramp[ramp_size - i - 1]; r_ramp[ramp_size - i - 1] = tmpRampVal; tmpRampVal = g_ramp[i]; g_ramp[i] = g_ramp[ramp_size - i - 1]; g_ramp[ramp_size - i - 1] = tmpRampVal; tmpRampVal = b_ramp[i]; b_ramp[i] = b_ramp[ramp_size - i - 1]; b_ramp[ramp_size - i - 1] = tmpRampVal; } } if(calcloss) { fprintf(stdout, "Resolution loss for %d entries:\n", ramp_size); r_res = 0; g_res = 0; b_res = 0; tmpRampVal = 0xffff; for(i = 0; i < ramp_size; i++) { if ((r_ramp[i] & 0xff00) != (tmpRampVal & 0xff00)) { r_res++; } tmpRampVal = r_ramp[i]; } tmpRampVal = 0xffff; for(i = 0; i < ramp_size; i++) { if ((g_ramp[i] & 0xff00) != (tmpRampVal & 0xff00)) { g_res++; } tmpRampVal = g_ramp[i]; } tmpRampVal = 0xffff; for(i = 0; i < ramp_size; i++) { if ((b_ramp[i] & 0xff00) != (tmpRampVal & 0xff00)) { b_res++; } tmpRampVal = b_ramp[i]; } fprintf(stdout, "R: %d\tG: %d\t B: %d\t colors lost\n", ramp_size - r_res, ramp_size - g_res, ramp_size - b_res ); } #ifdef WIN32GDI for (i = 0; i < ramp_size; i++) { winGammaRamp.Red[i] = r_ramp[i]; winGammaRamp.Green[i] = g_ramp[i]; winGammaRamp.Blue[i] = b_ramp[i]; } #endif if(printramps) for(i=0; i> 6; fglrx_gammaramps.GGamma[i] = g_ramp[i] >> 6; fglrx_gammaramps.BGamma[i] = b_ramp[i] >> 6; } if (!FGLRX_X11SetGammaRamp_C16native_1024(dpy, screen, controller, ramp_size, &fglrx_gammaramps)) # else if (!XF86VidModeSetGammaRamp (dpy, screen, ramp_size, r_ramp, g_ramp, b_ramp)) # endif #else if (!SetDeviceGammaRamp(hDc, &winGammaRamp)) #endif warning ("Unable to calibrate display"); } message ("X-LUT size: \t%d\n", ramp_size); free(r_ramp); free(g_ramp); free(b_ramp); cleanupX: #ifndef WIN32GDI if(dpy) if(!donothing) XCloseDisplay (dpy); #endif return 0; } /* Basic printf type error() and warning() routines */ /* errors are printed to stderr */ void error (char *fmt, ...) { va_list args; fprintf (stderr, "Error - "); va_start (args, fmt); vfprintf (stderr, fmt, args); va_end (args); fprintf (stderr, "\n"); exit (-1); } /* warnings are printed to stdout */ void warning (char *fmt, ...) { va_list args; fprintf (stdout, "Warning - "); va_start (args, fmt); vfprintf (stdout, fmt, args); va_end (args); fprintf (stdout, "\n"); } /* messages are printed only if the verbose flag is set */ void message (char *fmt, ...) { va_list args; if(xcalib_state.verbose) { va_start (args, fmt); vfprintf (stdout, fmt, args); va_end (args); } }