1
0
mirror of https://github.com/moparisthebest/Simba synced 2024-11-28 03:52:23 -05:00
Simba/Units/MMLCore/colour_conv.pas

390 lines
9.5 KiB
ObjectPascal
Raw Normal View History

{
This file is part of the Mufasa Macro Library (MML)
Copyright (c) 2009 by Raymond van Venetië and Merlijn Wajer
MML 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 3 of the License, or
(at your option) any later version.
MML 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 MML. If not, see <http://www.gnu.org/licenses/>.
See the file COPYING, included in this distribution,
for details about the copyright.
Colour Conversion Utilities for the Mufasa Macro Library
}
unit colour_conv;
{$mode objfpc}{$H+}
{$Inline on}
interface
uses
Classes, SysUtils,
Graphics, mufasatypes,
Math;
Function RGBtoColor(r,g,b : byte) : TColor; overload; inline;
Function RGBtoColor(r,g,b : integer) : TColor; overload; inline;
Procedure ColorToRGB(Color : integer;out r,g,b : byte); overload; inline;
Procedure ColorToRGB(Color : integer;out r,g,b : integer); overload; inline;
Procedure RGBToXYZ(R,G,B : byte;out x,y,z : Extended); inline;
Procedure XYZToRGB(X,Y,Z : Extended;out R,G,B: byte); inline;
Procedure RGBToHSL(RR,GG,BB : byte;out H,S,L : Extended); inline;
Procedure RGBToHSLNonFixed(RR,GG,BB : byte;out H,S,L : Extended); inline;
Procedure HSLtoRGB(H,S,L : extended;out R,G,B : Byte); inline;
Procedure ColorToHSL(Col: Integer; out h, s, l: Extended); inline;
procedure ColorToXYZ(color: Integer; out X, Y, Z: Extended); inline;
function XYZToColor(X, Y, Z: Extended): TColor; inline;
function HSLToColor(H, S, L: Extended): TColor; inline;
function BGRToRGB(BGR : TRGB32) : TColor;inline;
Merge new CTS/Finder system. Touches pretty much all the functions in finder.pas, so I expect a lot of functions to break. Tests will have to be written and results will have to be compared with Simba 0.97. Still, I think it's ready for merging to simba-next. Squashed commit of the following: commit ef3bfa64105117326f72fab0e2d0112c3393c50a Merge: d1e3645 5b3e2a8 Author: Merlijn Wajer <merlijn@wizzup.org> Date: Thu Aug 4 00:44:01 2011 +0200 Merge branch 'simba-next' into cts-rework commit 5b3e2a864b9f2e266766cc1a8fba5e157e862386 Author: Merlijn Wajer <merlijn@wizzup.org> Date: Thu Aug 4 00:41:00 2011 +0200 Merge new CTS/Finder system. Touches pretty much all the functions in finder.pas, so I expect a lot of functions to break. Tests will have to be written and results will have to be compared with Simba 0.97. Still, I think it's ready for merging to simba-next. Squashed commit of the following: commit d1e3645ee5cc5793392ab0f5c178ef018a84adb0 Author: Merlijn Wajer <merlijn@wizzup.org> Date: Mon Aug 1 19:08:23 2011 +0200 MML/Finder: Fix all compiler hints + bug. commit f159f20bc2ce51414f0af47d9e17f4ed337077bb Author: Merlijn Wajer <merlijn@wizzup.org> Date: Mon Aug 1 19:05:03 2011 +0200 MML/Finder: Fix FindDTMsRotated. commit 1fc33752e4e75aa3c96b7f24bba53ee98dfc60ed Author: Merlijn Wajer <merlijn@wizzup.org> Date: Mon Aug 1 19:04:16 2011 +0200 MML/Finder: FindDTMsRotated rework. commit a621a6e8daf3a4ab6e177ee2ae86808bbb7633fb Author: Merlijn Wajer <merlijn@wizzup.org> Date: Mon Aug 1 18:13:36 2011 +0200 MML/Finder: FindDTMs rework done. commit 0b592eef86629fec6c791aed6cc0359c18586e62 Merge: 56e01c6 aaafd6b Author: Merlijn Wajer <merlijn@wizzup.org> Date: Mon Aug 1 16:48:09 2011 +0200 Merge branch 'master' into cts-rework Conflicts: Units/MMLCore/finder.pas commit 56e01c67fa031b36647a4f4e36b736c3f664d779 Author: Merlijn Wajer <merlijn@wizzup.org> Date: Mon Aug 1 16:16:19 2011 +0200 MML/Finder: CTS: Bitmap+Color functions done. Only DTM to go. commit 464b90d42bccf931451054b350ac53402aec4192 Author: Merlijn Wajer <merlijn@wizzup.org> Date: Mon Aug 1 13:58:49 2011 +0200 MMLCore/finder: Small cleanup. commit 2414f60c083ace5ca1c1e1f8f8eb54b245b4f2ba Merge: 55b0435 a20a31a Author: Merlijn Wajer <merlijn@wizzup.org> Date: Sun Jul 31 18:12:41 2011 +0200 Merge branch 'master' into cts-rework commit 55b0435a4e77206d018793acebdd988968218a3a Author: Merlijn Wajer <merlijn@wizzup.org> Date: Sat Jul 30 20:27:54 2011 +0200 Tests: Update BmpBench. commit 013daccf0770abc0d7fc1f2b8c07a2e6d2419dd8 Author: Merlijn Wajer <merlijn@wizzup.org> Date: Sat Jul 30 20:09:31 2011 +0200 MML/Core: Cleanup. commit 6f32e21291a863e9187b05e38a940a4921105b37 Author: Merlijn Wajer <merlijn@wizzup.org> Date: Sat Jul 30 20:08:17 2011 +0200 MML/Core: FindBitmapToleranceIn seems to work. commit 3b939443e81540dfac64c22c10558fd9d0bac7cd Author: Merlijn Wajer <merlijn@wizzup.org> Date: Sat Jul 30 19:10:10 2011 +0200 MML/Core: FindBitmapToleranceIn is nearly finished. Speed is nice, results are not accurate yet. I probably missed something when pre-loading the data. commit 0422f0eb5a89159c4019ec9066d7bae9dbfc267c Author: Merlijn Wajer <merlijn@wizzup.org> Date: Sat Jul 30 15:53:48 2011 +0200 MML/Core: Fixes for FindBitmapToleranceIn. commit 65f4ae16edb75065fef8ff802580de6627501ac7 Merge: daff307 353d1f3 Author: Merlijn Wajer <merlijn@wizzup.org> Date: Sat Jul 30 14:32:46 2011 +0200 Merge branch 'master' into cts-rework commit daff307f3d8062e1643a99ca2a8940c6199c20c0 Author: Merlijn Wajer <merlijn@wizzup.org> Date: Sat Jul 30 13:46:10 2011 +0200 Tests: Add BmpBench. commit cdb89a1802fb45583e6d49a171c0b50d34a625d5 Author: Merlijn Wajer <merlijn@wizzup.org> Date: Sat Jul 30 13:12:21 2011 +0200 MMLCore: FindBitmapToleranceIn cts rewrite. commit d0bd81c2e9e314ffe98bc58afdc35cd467090722 Merge: 3282636 da0de6e Author: Merlijn Wajer <merlijn@wizzup.org> Date: Sat Jul 30 00:15:50 2011 +0200 Merge branch 'master' into cts-rework commit 32826361789890c8aaa65a06bebd022faabb6f05 Merge: 7c86003 a8cdf77 Author: Merlijn Wajer <merlijn@wizzup.org> Date: Mon Jul 25 16:50:43 2011 +0200 Merge branch 'master' into cts-rework commit 7c8600311c1792c9411826040dc804860775a6be Merge: 153025f e0767cb Author: Merlijn Wajer <merlijn@wizzup.org> Date: Sun Jul 24 00:14:53 2011 +0200 Merge branch 'master' into cts-rework Conflicts: Doc/sphinx/conf.py Doc/sphinx/libmml/intro.rst commit 153025f08035a1125010bd6b7bf62dca57f084a0 Author: Merlijn Wajer <merlijn@wizzup.org> Date: Sun Jul 17 19:51:16 2011 +0200 libMML: Changed the indentation. commit 8abd502580fa782541095cdcb04cb3ba99f304cd Author: Merlijn Wajer <merlijn@wizzup.org> Date: Sun Jul 17 19:37:33 2011 +0200 Documentation: Bump version to 820. commit 031654b3d1120de61fc3a5b7923656f6d0108e2d Author: Merlijn Wajer <merlijn@wizzup.org> Date: Sun Jul 17 19:36:21 2011 +0200 Documentation: Initial libMML documentation. commit f91c9ffb0e31871c51995cf030bd811d76c8b438 Merge: f5c9690 989d077 Author: Merlijn Wajer <merlijn@wizzup.org> Date: Thu Jul 7 12:00:58 2011 +0200 Merge branch 'master' into cts-rework commit f5c9690bee157f9e8dc82a7d23c5841629e8599c Author: Merlijn Wajer <merlijn@wizzup.org> Date: Thu Jul 7 11:59:15 2011 +0200 Finder: More rework and cleanups. commit 79021409d05c24da797f73299744e588effd381c Author: Merlijn Wajer <merlijn@wizzup.org> Date: Wed Jul 6 21:34:03 2011 +0200 Finder: CTS 2 fix. commit cda571dcb0a3f3f755a63978d07f2a25f83861a7 Author: Merlijn Wajer <merlijn@wizzup.org> Date: Wed Jul 6 21:06:17 2011 +0200 Finder: Remote tolerance param. Cleanups. commit 733a8cbf320ca29f1edf60b9e29f1ae5c0d68b67 Author: Merlijn Wajer <merlijn@wizzup.org> Date: Wed Jul 6 20:39:44 2011 +0200 Finder: More fixes. :-) commit e6b005b61f0a4c223d0e8c1f109d28aa48c0ad17 Author: Merlijn Wajer <merlijn@wizzup.org> Date: Wed Jul 6 18:34:49 2011 +0200 Finder: CTS-rework fixes. commit 6f896b56a292098a1aef2ddb138ea65ce96ec6a3 Author: Merlijn Wajer <merlijn@wizzup.org> Date: Wed Jul 6 18:15:33 2011 +0200 Finder: Start CTS rework. commit a63039914878e2eb40ff21a9c76f757b6e785716 Author: Merlijn Wajer <merlijn@wizzup.org> Date: Wed Jul 6 13:01:22 2011 +0200 Small TODO update. commit 0e6bf83a5cf5fa9d319fe10276f3f2291025b543 Merge: f19fd6b f2873b1 Author: Merlijn Wajer <merlijn@wizzup.org> Date: Wed Jul 6 12:59:09 2011 +0200 Merge branch 'master' into cts-rework commit f19fd6bf8d3589c196d063e1ff4962994606af55 Author: Merlijn Wajer <merlijn@wizzup.org> Date: Sun Jul 3 20:42:14 2011 +0200 Simba/Doc: Add Raymond to doc. commit 451ab89db36cc9b0fa5508a56917291918a1127f Merge: 37183f5 35026bc Author: Merlijn Wajer <merlijn@wizzup.org> Date: Sat Jul 2 14:48:43 2011 +0200 Merge branch 'master' into cts-rework commit 37183f5fd0baaa46f3726ce835f009153ef611d0 Merge: cca7b05 6873e72 Author: Merlijn Wajer <merlijn@wizzup.org> Date: Tue Jun 28 22:10:02 2011 +0200 Merge branch 'master' into cts-rework commit cca7b052135c874064ae9277956a7d078a58dbaf Author: Merlijn Wajer <merlijn@wizzup.org> Date: Thu Jun 16 17:03:14 2011 +0200 Add CTS 3 to FindColorsTolerance. Conflicts: Units/MMLCore/finder.pas commit c837d9b96057a58e4cd1a1d5efa241118e1e7d7d Author: Merlijn Wajer <merlijn@wizzup.org> Date: Thu Jun 16 16:33:25 2011 +0200 CTS 3: Fix typo. commit 52db461f845694d89254c7f0ea5d5fecfc9764f7 Author: Merlijn Wajer <merlijn@wizzup.org> Date: Mon Jun 6 16:06:17 2011 +0200 CTS 3: Now implement the formula properly. commit 7a0db25416639e76234b239a854b510e2043a91b Author: Merlijn Wajer <merlijn@wizzup.org> Date: Sun Jun 5 19:44:52 2011 +0200 Add L*a*b CTS (3). commit 2e1e786d0ece69dc3e42fb92106a71dce0faf975 Author: Merlijn Wajer <merlijn@wizzup.org> Date: Thu Jun 16 15:11:17 2011 +0200 FindBitmapToleranceIn now works. commit 58ea6021cd0cee3bd54f8ce93713bedc9ff3feb4 Author: Merlijn Wajer <merlijn@wizzup.org> Date: Thu Jun 16 14:26:20 2011 +0200 CTS work. CTS 2 is still broken for bitmaps. commit 91d952d33ab9b8ddcb76bed991a1ea0c5907e084 Author: Merlijn Wajer <merlijn@wizzup.org> Date: Thu Jun 16 12:52:10 2011 +0200 CTS cleanups. commit d9836a251c3ed4a3367383b7e182c648905fabee Merge: 5bf7d8b bfc3f86 Author: Merlijn Wajer <merlijn@wizzup.org> Date: Mon Jun 13 20:44:08 2011 +0200 Merge branch 'master' into cts-rework commit 5bf7d8beeaf69133b03a3f8c04124f33dea4e24c Author: Merlijn Wajer <merlijn@wizzup.org> Date: Mon Jun 13 20:38:00 2011 +0200 Completed first CTS rework. commit 7a412d16704f270ba44674c8422e1272c8994b11 Author: Merlijn Wajer <merlijn@wizzup.org> Date: Mon Jun 13 20:21:23 2011 +0200 CTS: Cleanups. commit 14474a84ab69e15a1de3998dc01cb3053daba384 Author: Merlijn Wajer <merlijn@wizzup.org> Date: Mon Jun 13 18:16:59 2011 +0200 CTS rework for FindColorsTolerance. commit b87a123701fb192b2f31efb8896d7e661b399c32 Author: Merlijn Wajer <merlijn@wizzup.org> Date: Mon Jun 13 17:44:04 2011 +0200 More cleanups to CTS. commit 9415d0810088c37e7f0f79e2a31c7e723bd6152c Author: Merlijn Wajer <merlijn@wizzup.org> Date: Mon Jun 13 17:41:06 2011 +0200 Finder: Trying a different CTS approach. commit d1e3645ee5cc5793392ab0f5c178ef018a84adb0 Author: Merlijn Wajer <merlijn@wizzup.org> Date: Mon Aug 1 19:08:23 2011 +0200 MML/Finder: Fix all compiler hints + bug. commit f159f20bc2ce51414f0af47d9e17f4ed337077bb Author: Merlijn Wajer <merlijn@wizzup.org> Date: Mon Aug 1 19:05:03 2011 +0200 MML/Finder: Fix FindDTMsRotated. commit 1fc33752e4e75aa3c96b7f24bba53ee98dfc60ed Author: Merlijn Wajer <merlijn@wizzup.org> Date: Mon Aug 1 19:04:16 2011 +0200 MML/Finder: FindDTMsRotated rework. commit a621a6e8daf3a4ab6e177ee2ae86808bbb7633fb Author: Merlijn Wajer <merlijn@wizzup.org> Date: Mon Aug 1 18:13:36 2011 +0200 MML/Finder: FindDTMs rework done. commit 0b592eef86629fec6c791aed6cc0359c18586e62 Merge: 56e01c6 aaafd6b Author: Merlijn Wajer <merlijn@wizzup.org> Date: Mon Aug 1 16:48:09 2011 +0200 Merge branch 'master' into cts-rework Conflicts: Units/MMLCore/finder.pas commit 56e01c67fa031b36647a4f4e36b736c3f664d779 Author: Merlijn Wajer <merlijn@wizzup.org> Date: Mon Aug 1 16:16:19 2011 +0200 MML/Finder: CTS: Bitmap+Color functions done. Only DTM to go. commit 464b90d42bccf931451054b350ac53402aec4192 Author: Merlijn Wajer <merlijn@wizzup.org> Date: Mon Aug 1 13:58:49 2011 +0200 MMLCore/finder: Small cleanup. commit 2414f60c083ace5ca1c1e1f8f8eb54b245b4f2ba Merge: 55b0435 a20a31a Author: Merlijn Wajer <merlijn@wizzup.org> Date: Sun Jul 31 18:12:41 2011 +0200 Merge branch 'master' into cts-rework commit 55b0435a4e77206d018793acebdd988968218a3a Author: Merlijn Wajer <merlijn@wizzup.org> Date: Sat Jul 30 20:27:54 2011 +0200 Tests: Update BmpBench. commit 013daccf0770abc0d7fc1f2b8c07a2e6d2419dd8 Author: Merlijn Wajer <merlijn@wizzup.org> Date: Sat Jul 30 20:09:31 2011 +0200 MML/Core: Cleanup. commit 6f32e21291a863e9187b05e38a940a4921105b37 Author: Merlijn Wajer <merlijn@wizzup.org> Date: Sat Jul 30 20:08:17 2011 +0200 MML/Core: FindBitmapToleranceIn seems to work. commit 3b939443e81540dfac64c22c10558fd9d0bac7cd Author: Merlijn Wajer <merlijn@wizzup.org> Date: Sat Jul 30 19:10:10 2011 +0200 MML/Core: FindBitmapToleranceIn is nearly finished. Speed is nice, results are not accurate yet. I probably missed something when pre-loading the data. commit 0422f0eb5a89159c4019ec9066d7bae9dbfc267c Author: Merlijn Wajer <merlijn@wizzup.org> Date: Sat Jul 30 15:53:48 2011 +0200 MML/Core: Fixes for FindBitmapToleranceIn. commit 65f4ae16edb75065fef8ff802580de6627501ac7 Merge: daff307 353d1f3 Author: Merlijn Wajer <merlijn@wizzup.org> Date: Sat Jul 30 14:32:46 2011 +0200 Merge branch 'master' into cts-rework commit daff307f3d8062e1643a99ca2a8940c6199c20c0 Author: Merlijn Wajer <merlijn@wizzup.org> Date: Sat Jul 30 13:46:10 2011 +0200 Tests: Add BmpBench. commit cdb89a1802fb45583e6d49a171c0b50d34a625d5 Author: Merlijn Wajer <merlijn@wizzup.org> Date: Sat Jul 30 13:12:21 2011 +0200 MMLCore: FindBitmapToleranceIn cts rewrite. commit d0bd81c2e9e314ffe98bc58afdc35cd467090722 Merge: 3282636 da0de6e Author: Merlijn Wajer <merlijn@wizzup.org> Date: Sat Jul 30 00:15:50 2011 +0200 Merge branch 'master' into cts-rework commit 32826361789890c8aaa65a06bebd022faabb6f05 Merge: 7c86003 a8cdf77 Author: Merlijn Wajer <merlijn@wizzup.org> Date: Mon Jul 25 16:50:43 2011 +0200 Merge branch 'master' into cts-rework commit 7c8600311c1792c9411826040dc804860775a6be Merge: 153025f e0767cb Author: Merlijn Wajer <merlijn@wizzup.org> Date: Sun Jul 24 00:14:53 2011 +0200 Merge branch 'master' into cts-rework Conflicts: Doc/sphinx/conf.py Doc/sphinx/libmml/intro.rst commit 153025f08035a1125010bd6b7bf62dca57f084a0 Author: Merlijn Wajer <merlijn@wizzup.org> Date: Sun Jul 17 19:51:16 2011 +0200 libMML: Changed the indentation. commit 8abd502580fa782541095cdcb04cb3ba99f304cd Author: Merlijn Wajer <merlijn@wizzup.org> Date: Sun Jul 17 19:37:33 2011 +0200 Documentation: Bump version to 820. commit 031654b3d1120de61fc3a5b7923656f6d0108e2d Author: Merlijn Wajer <merlijn@wizzup.org> Date: Sun Jul 17 19:36:21 2011 +0200 Documentation: Initial libMML documentation. commit f91c9ffb0e31871c51995cf030bd811d76c8b438 Merge: f5c9690 989d077 Author: Merlijn Wajer <merlijn@wizzup.org> Date: Thu Jul 7 12:00:58 2011 +0200 Merge branch 'master' into cts-rework commit f5c9690bee157f9e8dc82a7d23c5841629e8599c Author: Merlijn Wajer <merlijn@wizzup.org> Date: Thu Jul 7 11:59:15 2011 +0200 Finder: More rework and cleanups. commit 79021409d05c24da797f73299744e588effd381c Author: Merlijn Wajer <merlijn@wizzup.org> Date: Wed Jul 6 21:34:03 2011 +0200 Finder: CTS 2 fix. commit cda571dcb0a3f3f755a63978d07f2a25f83861a7 Author: Merlijn Wajer <merlijn@wizzup.org> Date: Wed Jul 6 21:06:17 2011 +0200 Finder: Remote tolerance param. Cleanups. commit 733a8cbf320ca29f1edf60b9e29f1ae5c0d68b67 Author: Merlijn Wajer <merlijn@wizzup.org> Date: Wed Jul 6 20:39:44 2011 +0200 Finder: More fixes. :-) commit e6b005b61f0a4c223d0e8c1f109d28aa48c0ad17 Author: Merlijn Wajer <merlijn@wizzup.org> Date: Wed Jul 6 18:34:49 2011 +0200 Finder: CTS-rework fixes. commit 6f896b56a292098a1aef2ddb138ea65ce96ec6a3 Author: Merlijn Wajer <merlijn@wizzup.org> Date: Wed Jul 6 18:15:33 2011 +0200 Finder: Start CTS rework. commit a63039914878e2eb40ff21a9c76f757b6e785716 Author: Merlijn Wajer <merlijn@wizzup.org> Date: Wed Jul 6 13:01:22 2011 +0200 Small TODO update. commit 0e6bf83a5cf5fa9d319fe10276f3f2291025b543 Merge: f19fd6b f2873b1 Author: Merlijn Wajer <merlijn@wizzup.org> Date: Wed Jul 6 12:59:09 2011 +0200 Merge branch 'master' into cts-rework commit f19fd6bf8d3589c196d063e1ff4962994606af55 Author: Merlijn Wajer <merlijn@wizzup.org> Date: Sun Jul 3 20:42:14 2011 +0200 Simba/Doc: Add Raymond to doc. commit 451ab89db36cc9b0fa5508a56917291918a1127f Merge: 37183f5 35026bc Author: Merlijn Wajer <merlijn@wizzup.org> Date: Sat Jul 2 14:48:43 2011 +0200 Merge branch 'master' into cts-rework commit 37183f5fd0baaa46f3726ce835f009153ef611d0 Merge: cca7b05 6873e72 Author: Merlijn Wajer <merlijn@wizzup.org> Date: Tue Jun 28 22:10:02 2011 +0200 Merge branch 'master' into cts-rework commit cca7b052135c874064ae9277956a7d078a58dbaf Author: Merlijn Wajer <merlijn@wizzup.org> Date: Thu Jun 16 17:03:14 2011 +0200 Add CTS 3 to FindColorsTolerance. Conflicts: Units/MMLCore/finder.pas commit c837d9b96057a58e4cd1a1d5efa241118e1e7d7d Author: Merlijn Wajer <merlijn@wizzup.org> Date: Thu Jun 16 16:33:25 2011 +0200 CTS 3: Fix typo. commit 52db461f845694d89254c7f0ea5d5fecfc9764f7 Author: Merlijn Wajer <merlijn@wizzup.org> Date: Mon Jun 6 16:06:17 2011 +0200 CTS 3: Now implement the formula properly. commit 7a0db25416639e76234b239a854b510e2043a91b Author: Merlijn Wajer <merlijn@wizzup.org> Date: Sun Jun 5 19:44:52 2011 +0200 Add L*a*b CTS (3). commit 2e1e786d0ece69dc3e42fb92106a71dce0faf975 Author: Merlijn Wajer <merlijn@wizzup.org> Date: Thu Jun 16 15:11:17 2011 +0200 FindBitmapToleranceIn now works. commit 58ea6021cd0cee3bd54f8ce93713bedc9ff3feb4 Author: Merlijn Wajer <merlijn@wizzup.org> Date: Thu Jun 16 14:26:20 2011 +0200 CTS work. CTS 2 is still broken for bitmaps. commit 91d952d33ab9b8ddcb76bed991a1ea0c5907e084 Author: Merlijn Wajer <merlijn@wizzup.org> Date: Thu Jun 16 12:52:10 2011 +0200 CTS cleanups. commit d9836a251c3ed4a3367383b7e182c648905fabee Merge: 5bf7d8b bfc3f86 Author: Merlijn Wajer <merlijn@wizzup.org> Date: Mon Jun 13 20:44:08 2011 +0200 Merge branch 'master' into cts-rework commit 5bf7d8beeaf69133b03a3f8c04124f33dea4e24c Author: Merlijn Wajer <merlijn@wizzup.org> Date: Mon Jun 13 20:38:00 2011 +0200 Completed first CTS rework. commit 7a412d16704f270ba44674c8422e1272c8994b11 Author: Merlijn Wajer <merlijn@wizzup.org> Date: Mon Jun 13 20:21:23 2011 +0200 CTS: Cleanups. commit 14474a84ab69e15a1de3998dc01cb3053daba384 Author: Merlijn Wajer <merlijn@wizzup.org> Date: Mon Jun 13 18:16:59 2011 +0200 CTS rework for FindColorsTolerance. commit b87a123701fb192b2f31efb8896d7e661b399c32 Author: Merlijn Wajer <merlijn@wizzup.org> Date: Mon Jun 13 17:44:04 2011 +0200 More cleanups to CTS. commit 9415d0810088c37e7f0f79e2a31c7e723bd6152c Author: Merlijn Wajer <merlijn@wizzup.org> Date: Mon Jun 13 17:41:06 2011 +0200 Finder: Trying a different CTS approach.
2011-08-03 19:23:49 -04:00
procedure XYZtoCIELab(X, Y, Z: Extended; out L, a, b: Extended);
procedure CIELabtoXYZ(L, a, b: Extended; out X, Y, Z: Extended);
implementation
Const
OneDivThree = 1/3.0;
TwoDivThree = 2 / 3.0;
OneDivTwoPointFour = 1 / 2.4;
function BGRToRGB(BGR : TRGB32) : TColor;inline;
begin;
Result := BGR.R or BGR.g shl 8 or BGR.b shl 16;
end;
Function RGBtoColor(r,g,b : byte): TColor; overload; inline;
begin;
Result := R or g shl 8 or b shl 16;
end;
{/\
Translates the given Red (R), Green (G) and Blue (B) components to a TColor.
R, G and B are integers.
/\}
Function RGBtoColor(r,g,b : integer): TColor; overload; inline;
begin;
Result := R or g shl 8 or b shl 16;
end;
{/\
Translates the given win-32 color in the Red (R), Green (G) and Blue (B)
components. R, G and B are bytes.
/\}
Procedure ColorToRGB(Color : integer;out r,g,b : byte); overload; inline;
begin
R := Color and $ff;
G := Color shr 8 and $ff;
B := Color shr 16 and $ff;
end;
{/\
Translates the given win-32 color in the Red (R), Green (G) and Blue (B)
components. R, G and B are integers.
/\}
Procedure ColorToRGB(Color : integer;out r,g,b : integer); overload; inline;
begin
R := Color and $ff;
G := Color shr 8 and $ff;
B := Color shr 16 and $ff;
end;
{/\
Translates the given Red (R), Green (G) and Blue (B) components to
X, Y and Z components.
/\}
Procedure RGBToXYZ(R,G,B : byte;out x,y,z : Extended); inline;
var
Red,Green,Blue : Extended;
begin;
Red := R / 255;
Green := G / 255;
Blue := B / 255;
if Red > 0.04045 then
Red := Power( ( Red + 0.055 ) / 1.055 , 2.4) * 100
else
2010-12-12 05:49:50 -05:00
Red := Red * 7.73993808;
if Green > 0.04045 then
Green := Power( ( Green + 0.055 ) / 1.055 , 2.4) * 100
else
2010-12-12 05:49:50 -05:00
Green := Green * 7.73993808;
if Blue > 0.04045 then
Blue := Power( ( Blue + 0.055 ) / 1.055 , 2.4) * 100
else
2010-12-12 05:49:50 -05:00
Blue := Blue * 7.73993808;
X := Red * 0.4124 + Green * 0.3576 + Blue * 0.1805;
Y := Red * 0.2126 + Green * 0.7152 + Blue * 0.0722;
Z := Red * 0.0193 + Green * 0.1192 + Blue * 0.9505;
end;
{/\
Translates the given X, Y and Z components to
Red (R), Green (G) and Blue (B) components.
/\}
Procedure XYZToRGB(X,Y,Z : Extended;out R,G,B: byte); inline;
var
TempR,TempG,TempB,Tempx,tempy,tempz : Extended;
begin;
Tempx := X / 100;
tempy := Y / 100;
tempz := Z / 100;
TempR := Tempx * 3.2406 + tempy * -1.5372 + tempz * -0.4986;
TempG := Tempx * -0.9689 + tempy * 1.8758 + tempz * 0.0415;
TempB := Tempx * 0.0557 + tempy * -0.2040 + tempz * 1.0570;
if TempR > 0.0031308 then
TempR := 1.055 * ( Power(TempR, (OneDivTwoPointFour)) ) - 0.055
else
TempR := 12.92 * TempR;
if TempG > 0.0031308 then
TempG := 1.055 * ( Power(TempG, ( OneDivTwoPointFour)) ) - 0.055
else
TempG := 12.92 * TempG;
if TempB > 0.0031308 then
TempB := 1.055 * ( Power(TempB , ( OneDivTwoPointFour )) ) - 0.055
else
TempB := 12.92 * TempB;
R := Round(TempR * 255);
G := Round(TempG * 255);
B := Round(TempB * 255);
end;
{/\
Translates the given Red (R), Green (G) and Blue (B) components to
H (Hue), S (Saturation) and L (Luminance) components.
/\}
Procedure RGBToHSL(RR,GG,BB : byte;out H,S,L : Extended); inline;
var
R, G, B, D, Cmax, Cmin: Extended;
begin
R := RR / 255;
G := GG / 255;
B := BB / 255;
CMin := R;
if G < Cmin then Cmin := G;
if B < Cmin then Cmin := B;
CMax := R;
if G > Cmax then Cmax := G;
if B > Cmax then Cmax := B;
L := 0.5 * (Cmax + Cmin);
if Cmax = Cmin then
begin
H := 0;
S := 0;
end else
begin;
D := Cmax - Cmin;
if L < 0.5 then
S := D / (Cmax + Cmin)
else
S := D / (2 - Cmax - Cmin);
if R = Cmax then
H := (G - B) / D
else
if G = Cmax then
H := 2 + (B - R) / D
else
H := 4 + (R - G) / D;
H := H / 6;
if H < 0 then
H := H + 1;
end;
H := H * 100;
S := S * 100;
L := L * 100;
end;
{/\
Translates the given Red (R), Green (G) and Blue (B) components to
H (Hue), S (Saturation) and L (Luminance) components.
This function does not multiply it by 100.
/\}
Procedure RGBToHSLNonFixed(RR,GG,BB : byte;out H,S,L : Extended); inline;
var
R, G, B, D, Cmax, Cmin: Extended;
begin
R := RR / 255;
G := GG / 255;
B := BB / 255;
CMin := R;
if G < Cmin then Cmin := G;
if B < Cmin then Cmin := B;
CMax := R;
if G > Cmax then Cmax := G;
if B > Cmax then Cmax := B;
L := 0.5 * (Cmax + Cmin);
if Cmax = Cmin then
begin
H := 0;
S := 0;
end else
begin;
D := Cmax - Cmin;
if L < 0.5 then
S := D / (Cmax + Cmin)
else
S := D / (2 - Cmax - Cmin);
if R = Cmax then
H := (G - B) / D
else
if G = Cmax then
H := 2 + (B - R) / D
else
H := 4 + (R - G) / D;
H := H / 6;
if H < 0 then
H := H + 1;
end;
end;
{/\
Translates the given H (Hue), S (Saturation) and L (Luminance) components to
Red (R), Green (G) and Blue (B) components.
/\}
procedure HSLtoRGB(H, S, L: extended; out R, G, B: Byte); inline;
var
Temp,Temp2 : Extended;
//begin
Function Hue2RGB(TempHue : Extended) : integer;
begin;
if TempHue < 0 then
TempHue := TempHue + 1
else if TempHue > 1 then
TempHue := TempHue - 1;
if ( ( 6 * TempHue ) < 1 ) then
Result :=Round(255 * (( Temp + ( Temp2 - Temp ) * 6 * TempHue )))
else if ( ( 2 * TempHue ) < 1 ) then
Result :=Round(255 * Temp2)
else if ( ( 3 * TempHue ) < 2 ) then
Result :=Round(255 * (Temp + ( Temp2 - Temp ) * ( ( TwoDivThree ) - TempHue ) * 6))
else
Result :=Round(255 * Temp);
end;
begin;
H := H / 100;
S := S / 100;
L := L / 100;
if s = 0 then
begin;
R := Byte(Round(L * 255));
G := R;
B := R;
end else
begin;
if (L < 0.5) then
Temp2 := L * ( 1 + S )
else
Temp2 := (L + S) - ( S * L);
Temp := 2 * L - Temp2;
R := Hue2RGB( H + ( OneDivThree ) );
G := Hue2RGB( H );
B := Hue2RGB( H - ( OneDivThree ) );
end;
end;
{/\
Split the Given Color col in H, S, L components.
/\}
Procedure ColorToHSL(Col: Integer; out h, s, l: Extended); inline;
Var
R, G, B: byte;
Begin
ColorToRGB(Col, R, G, B);
RGBToHSL(R, G, B, H, S, L);
End;
procedure ColorToXYZ(color: Integer; out X, Y, Z: Extended); inline;
var
R, G, B: byte;
begin
ColorToRGB(Color, R, G, B);
RGBToXYZ(R, G, B, X, Y, Z);
end;
function HSLToColor(H, S, L: Extended): TColor; inline;
var
r, g, b: byte;
begin
HSLToRGB(H, S, L, r, g, b);
Result := RGBToColor(r, g, b);
end;
function XYZToColor(X, Y, Z: Extended): TColor; inline;
var
r, g, b: byte;
begin
XYZToRGB(X, Y, Z, r, g, b);
Result := RGBToColor(r, g, b);
end;
Merge new CTS/Finder system. Touches pretty much all the functions in finder.pas, so I expect a lot of functions to break. Tests will have to be written and results will have to be compared with Simba 0.97. Still, I think it's ready for merging to simba-next. Squashed commit of the following: commit ef3bfa64105117326f72fab0e2d0112c3393c50a Merge: d1e3645 5b3e2a8 Author: Merlijn Wajer <merlijn@wizzup.org> Date: Thu Aug 4 00:44:01 2011 +0200 Merge branch 'simba-next' into cts-rework commit 5b3e2a864b9f2e266766cc1a8fba5e157e862386 Author: Merlijn Wajer <merlijn@wizzup.org> Date: Thu Aug 4 00:41:00 2011 +0200 Merge new CTS/Finder system. Touches pretty much all the functions in finder.pas, so I expect a lot of functions to break. Tests will have to be written and results will have to be compared with Simba 0.97. Still, I think it's ready for merging to simba-next. Squashed commit of the following: commit d1e3645ee5cc5793392ab0f5c178ef018a84adb0 Author: Merlijn Wajer <merlijn@wizzup.org> Date: Mon Aug 1 19:08:23 2011 +0200 MML/Finder: Fix all compiler hints + bug. commit f159f20bc2ce51414f0af47d9e17f4ed337077bb Author: Merlijn Wajer <merlijn@wizzup.org> Date: Mon Aug 1 19:05:03 2011 +0200 MML/Finder: Fix FindDTMsRotated. commit 1fc33752e4e75aa3c96b7f24bba53ee98dfc60ed Author: Merlijn Wajer <merlijn@wizzup.org> Date: Mon Aug 1 19:04:16 2011 +0200 MML/Finder: FindDTMsRotated rework. commit a621a6e8daf3a4ab6e177ee2ae86808bbb7633fb Author: Merlijn Wajer <merlijn@wizzup.org> Date: Mon Aug 1 18:13:36 2011 +0200 MML/Finder: FindDTMs rework done. commit 0b592eef86629fec6c791aed6cc0359c18586e62 Merge: 56e01c6 aaafd6b Author: Merlijn Wajer <merlijn@wizzup.org> Date: Mon Aug 1 16:48:09 2011 +0200 Merge branch 'master' into cts-rework Conflicts: Units/MMLCore/finder.pas commit 56e01c67fa031b36647a4f4e36b736c3f664d779 Author: Merlijn Wajer <merlijn@wizzup.org> Date: Mon Aug 1 16:16:19 2011 +0200 MML/Finder: CTS: Bitmap+Color functions done. Only DTM to go. commit 464b90d42bccf931451054b350ac53402aec4192 Author: Merlijn Wajer <merlijn@wizzup.org> Date: Mon Aug 1 13:58:49 2011 +0200 MMLCore/finder: Small cleanup. commit 2414f60c083ace5ca1c1e1f8f8eb54b245b4f2ba Merge: 55b0435 a20a31a Author: Merlijn Wajer <merlijn@wizzup.org> Date: Sun Jul 31 18:12:41 2011 +0200 Merge branch 'master' into cts-rework commit 55b0435a4e77206d018793acebdd988968218a3a Author: Merlijn Wajer <merlijn@wizzup.org> Date: Sat Jul 30 20:27:54 2011 +0200 Tests: Update BmpBench. commit 013daccf0770abc0d7fc1f2b8c07a2e6d2419dd8 Author: Merlijn Wajer <merlijn@wizzup.org> Date: Sat Jul 30 20:09:31 2011 +0200 MML/Core: Cleanup. commit 6f32e21291a863e9187b05e38a940a4921105b37 Author: Merlijn Wajer <merlijn@wizzup.org> Date: Sat Jul 30 20:08:17 2011 +0200 MML/Core: FindBitmapToleranceIn seems to work. commit 3b939443e81540dfac64c22c10558fd9d0bac7cd Author: Merlijn Wajer <merlijn@wizzup.org> Date: Sat Jul 30 19:10:10 2011 +0200 MML/Core: FindBitmapToleranceIn is nearly finished. Speed is nice, results are not accurate yet. I probably missed something when pre-loading the data. commit 0422f0eb5a89159c4019ec9066d7bae9dbfc267c Author: Merlijn Wajer <merlijn@wizzup.org> Date: Sat Jul 30 15:53:48 2011 +0200 MML/Core: Fixes for FindBitmapToleranceIn. commit 65f4ae16edb75065fef8ff802580de6627501ac7 Merge: daff307 353d1f3 Author: Merlijn Wajer <merlijn@wizzup.org> Date: Sat Jul 30 14:32:46 2011 +0200 Merge branch 'master' into cts-rework commit daff307f3d8062e1643a99ca2a8940c6199c20c0 Author: Merlijn Wajer <merlijn@wizzup.org> Date: Sat Jul 30 13:46:10 2011 +0200 Tests: Add BmpBench. commit cdb89a1802fb45583e6d49a171c0b50d34a625d5 Author: Merlijn Wajer <merlijn@wizzup.org> Date: Sat Jul 30 13:12:21 2011 +0200 MMLCore: FindBitmapToleranceIn cts rewrite. commit d0bd81c2e9e314ffe98bc58afdc35cd467090722 Merge: 3282636 da0de6e Author: Merlijn Wajer <merlijn@wizzup.org> Date: Sat Jul 30 00:15:50 2011 +0200 Merge branch 'master' into cts-rework commit 32826361789890c8aaa65a06bebd022faabb6f05 Merge: 7c86003 a8cdf77 Author: Merlijn Wajer <merlijn@wizzup.org> Date: Mon Jul 25 16:50:43 2011 +0200 Merge branch 'master' into cts-rework commit 7c8600311c1792c9411826040dc804860775a6be Merge: 153025f e0767cb Author: Merlijn Wajer <merlijn@wizzup.org> Date: Sun Jul 24 00:14:53 2011 +0200 Merge branch 'master' into cts-rework Conflicts: Doc/sphinx/conf.py Doc/sphinx/libmml/intro.rst commit 153025f08035a1125010bd6b7bf62dca57f084a0 Author: Merlijn Wajer <merlijn@wizzup.org> Date: Sun Jul 17 19:51:16 2011 +0200 libMML: Changed the indentation. commit 8abd502580fa782541095cdcb04cb3ba99f304cd Author: Merlijn Wajer <merlijn@wizzup.org> Date: Sun Jul 17 19:37:33 2011 +0200 Documentation: Bump version to 820. commit 031654b3d1120de61fc3a5b7923656f6d0108e2d Author: Merlijn Wajer <merlijn@wizzup.org> Date: Sun Jul 17 19:36:21 2011 +0200 Documentation: Initial libMML documentation. commit f91c9ffb0e31871c51995cf030bd811d76c8b438 Merge: f5c9690 989d077 Author: Merlijn Wajer <merlijn@wizzup.org> Date: Thu Jul 7 12:00:58 2011 +0200 Merge branch 'master' into cts-rework commit f5c9690bee157f9e8dc82a7d23c5841629e8599c Author: Merlijn Wajer <merlijn@wizzup.org> Date: Thu Jul 7 11:59:15 2011 +0200 Finder: More rework and cleanups. commit 79021409d05c24da797f73299744e588effd381c Author: Merlijn Wajer <merlijn@wizzup.org> Date: Wed Jul 6 21:34:03 2011 +0200 Finder: CTS 2 fix. commit cda571dcb0a3f3f755a63978d07f2a25f83861a7 Author: Merlijn Wajer <merlijn@wizzup.org> Date: Wed Jul 6 21:06:17 2011 +0200 Finder: Remote tolerance param. Cleanups. commit 733a8cbf320ca29f1edf60b9e29f1ae5c0d68b67 Author: Merlijn Wajer <merlijn@wizzup.org> Date: Wed Jul 6 20:39:44 2011 +0200 Finder: More fixes. :-) commit e6b005b61f0a4c223d0e8c1f109d28aa48c0ad17 Author: Merlijn Wajer <merlijn@wizzup.org> Date: Wed Jul 6 18:34:49 2011 +0200 Finder: CTS-rework fixes. commit 6f896b56a292098a1aef2ddb138ea65ce96ec6a3 Author: Merlijn Wajer <merlijn@wizzup.org> Date: Wed Jul 6 18:15:33 2011 +0200 Finder: Start CTS rework. commit a63039914878e2eb40ff21a9c76f757b6e785716 Author: Merlijn Wajer <merlijn@wizzup.org> Date: Wed Jul 6 13:01:22 2011 +0200 Small TODO update. commit 0e6bf83a5cf5fa9d319fe10276f3f2291025b543 Merge: f19fd6b f2873b1 Author: Merlijn Wajer <merlijn@wizzup.org> Date: Wed Jul 6 12:59:09 2011 +0200 Merge branch 'master' into cts-rework commit f19fd6bf8d3589c196d063e1ff4962994606af55 Author: Merlijn Wajer <merlijn@wizzup.org> Date: Sun Jul 3 20:42:14 2011 +0200 Simba/Doc: Add Raymond to doc. commit 451ab89db36cc9b0fa5508a56917291918a1127f Merge: 37183f5 35026bc Author: Merlijn Wajer <merlijn@wizzup.org> Date: Sat Jul 2 14:48:43 2011 +0200 Merge branch 'master' into cts-rework commit 37183f5fd0baaa46f3726ce835f009153ef611d0 Merge: cca7b05 6873e72 Author: Merlijn Wajer <merlijn@wizzup.org> Date: Tue Jun 28 22:10:02 2011 +0200 Merge branch 'master' into cts-rework commit cca7b052135c874064ae9277956a7d078a58dbaf Author: Merlijn Wajer <merlijn@wizzup.org> Date: Thu Jun 16 17:03:14 2011 +0200 Add CTS 3 to FindColorsTolerance. Conflicts: Units/MMLCore/finder.pas commit c837d9b96057a58e4cd1a1d5efa241118e1e7d7d Author: Merlijn Wajer <merlijn@wizzup.org> Date: Thu Jun 16 16:33:25 2011 +0200 CTS 3: Fix typo. commit 52db461f845694d89254c7f0ea5d5fecfc9764f7 Author: Merlijn Wajer <merlijn@wizzup.org> Date: Mon Jun 6 16:06:17 2011 +0200 CTS 3: Now implement the formula properly. commit 7a0db25416639e76234b239a854b510e2043a91b Author: Merlijn Wajer <merlijn@wizzup.org> Date: Sun Jun 5 19:44:52 2011 +0200 Add L*a*b CTS (3). commit 2e1e786d0ece69dc3e42fb92106a71dce0faf975 Author: Merlijn Wajer <merlijn@wizzup.org> Date: Thu Jun 16 15:11:17 2011 +0200 FindBitmapToleranceIn now works. commit 58ea6021cd0cee3bd54f8ce93713bedc9ff3feb4 Author: Merlijn Wajer <merlijn@wizzup.org> Date: Thu Jun 16 14:26:20 2011 +0200 CTS work. CTS 2 is still broken for bitmaps. commit 91d952d33ab9b8ddcb76bed991a1ea0c5907e084 Author: Merlijn Wajer <merlijn@wizzup.org> Date: Thu Jun 16 12:52:10 2011 +0200 CTS cleanups. commit d9836a251c3ed4a3367383b7e182c648905fabee Merge: 5bf7d8b bfc3f86 Author: Merlijn Wajer <merlijn@wizzup.org> Date: Mon Jun 13 20:44:08 2011 +0200 Merge branch 'master' into cts-rework commit 5bf7d8beeaf69133b03a3f8c04124f33dea4e24c Author: Merlijn Wajer <merlijn@wizzup.org> Date: Mon Jun 13 20:38:00 2011 +0200 Completed first CTS rework. commit 7a412d16704f270ba44674c8422e1272c8994b11 Author: Merlijn Wajer <merlijn@wizzup.org> Date: Mon Jun 13 20:21:23 2011 +0200 CTS: Cleanups. commit 14474a84ab69e15a1de3998dc01cb3053daba384 Author: Merlijn Wajer <merlijn@wizzup.org> Date: Mon Jun 13 18:16:59 2011 +0200 CTS rework for FindColorsTolerance. commit b87a123701fb192b2f31efb8896d7e661b399c32 Author: Merlijn Wajer <merlijn@wizzup.org> Date: Mon Jun 13 17:44:04 2011 +0200 More cleanups to CTS. commit 9415d0810088c37e7f0f79e2a31c7e723bd6152c Author: Merlijn Wajer <merlijn@wizzup.org> Date: Mon Jun 13 17:41:06 2011 +0200 Finder: Trying a different CTS approach. commit d1e3645ee5cc5793392ab0f5c178ef018a84adb0 Author: Merlijn Wajer <merlijn@wizzup.org> Date: Mon Aug 1 19:08:23 2011 +0200 MML/Finder: Fix all compiler hints + bug. commit f159f20bc2ce51414f0af47d9e17f4ed337077bb Author: Merlijn Wajer <merlijn@wizzup.org> Date: Mon Aug 1 19:05:03 2011 +0200 MML/Finder: Fix FindDTMsRotated. commit 1fc33752e4e75aa3c96b7f24bba53ee98dfc60ed Author: Merlijn Wajer <merlijn@wizzup.org> Date: Mon Aug 1 19:04:16 2011 +0200 MML/Finder: FindDTMsRotated rework. commit a621a6e8daf3a4ab6e177ee2ae86808bbb7633fb Author: Merlijn Wajer <merlijn@wizzup.org> Date: Mon Aug 1 18:13:36 2011 +0200 MML/Finder: FindDTMs rework done. commit 0b592eef86629fec6c791aed6cc0359c18586e62 Merge: 56e01c6 aaafd6b Author: Merlijn Wajer <merlijn@wizzup.org> Date: Mon Aug 1 16:48:09 2011 +0200 Merge branch 'master' into cts-rework Conflicts: Units/MMLCore/finder.pas commit 56e01c67fa031b36647a4f4e36b736c3f664d779 Author: Merlijn Wajer <merlijn@wizzup.org> Date: Mon Aug 1 16:16:19 2011 +0200 MML/Finder: CTS: Bitmap+Color functions done. Only DTM to go. commit 464b90d42bccf931451054b350ac53402aec4192 Author: Merlijn Wajer <merlijn@wizzup.org> Date: Mon Aug 1 13:58:49 2011 +0200 MMLCore/finder: Small cleanup. commit 2414f60c083ace5ca1c1e1f8f8eb54b245b4f2ba Merge: 55b0435 a20a31a Author: Merlijn Wajer <merlijn@wizzup.org> Date: Sun Jul 31 18:12:41 2011 +0200 Merge branch 'master' into cts-rework commit 55b0435a4e77206d018793acebdd988968218a3a Author: Merlijn Wajer <merlijn@wizzup.org> Date: Sat Jul 30 20:27:54 2011 +0200 Tests: Update BmpBench. commit 013daccf0770abc0d7fc1f2b8c07a2e6d2419dd8 Author: Merlijn Wajer <merlijn@wizzup.org> Date: Sat Jul 30 20:09:31 2011 +0200 MML/Core: Cleanup. commit 6f32e21291a863e9187b05e38a940a4921105b37 Author: Merlijn Wajer <merlijn@wizzup.org> Date: Sat Jul 30 20:08:17 2011 +0200 MML/Core: FindBitmapToleranceIn seems to work. commit 3b939443e81540dfac64c22c10558fd9d0bac7cd Author: Merlijn Wajer <merlijn@wizzup.org> Date: Sat Jul 30 19:10:10 2011 +0200 MML/Core: FindBitmapToleranceIn is nearly finished. Speed is nice, results are not accurate yet. I probably missed something when pre-loading the data. commit 0422f0eb5a89159c4019ec9066d7bae9dbfc267c Author: Merlijn Wajer <merlijn@wizzup.org> Date: Sat Jul 30 15:53:48 2011 +0200 MML/Core: Fixes for FindBitmapToleranceIn. commit 65f4ae16edb75065fef8ff802580de6627501ac7 Merge: daff307 353d1f3 Author: Merlijn Wajer <merlijn@wizzup.org> Date: Sat Jul 30 14:32:46 2011 +0200 Merge branch 'master' into cts-rework commit daff307f3d8062e1643a99ca2a8940c6199c20c0 Author: Merlijn Wajer <merlijn@wizzup.org> Date: Sat Jul 30 13:46:10 2011 +0200 Tests: Add BmpBench. commit cdb89a1802fb45583e6d49a171c0b50d34a625d5 Author: Merlijn Wajer <merlijn@wizzup.org> Date: Sat Jul 30 13:12:21 2011 +0200 MMLCore: FindBitmapToleranceIn cts rewrite. commit d0bd81c2e9e314ffe98bc58afdc35cd467090722 Merge: 3282636 da0de6e Author: Merlijn Wajer <merlijn@wizzup.org> Date: Sat Jul 30 00:15:50 2011 +0200 Merge branch 'master' into cts-rework commit 32826361789890c8aaa65a06bebd022faabb6f05 Merge: 7c86003 a8cdf77 Author: Merlijn Wajer <merlijn@wizzup.org> Date: Mon Jul 25 16:50:43 2011 +0200 Merge branch 'master' into cts-rework commit 7c8600311c1792c9411826040dc804860775a6be Merge: 153025f e0767cb Author: Merlijn Wajer <merlijn@wizzup.org> Date: Sun Jul 24 00:14:53 2011 +0200 Merge branch 'master' into cts-rework Conflicts: Doc/sphinx/conf.py Doc/sphinx/libmml/intro.rst commit 153025f08035a1125010bd6b7bf62dca57f084a0 Author: Merlijn Wajer <merlijn@wizzup.org> Date: Sun Jul 17 19:51:16 2011 +0200 libMML: Changed the indentation. commit 8abd502580fa782541095cdcb04cb3ba99f304cd Author: Merlijn Wajer <merlijn@wizzup.org> Date: Sun Jul 17 19:37:33 2011 +0200 Documentation: Bump version to 820. commit 031654b3d1120de61fc3a5b7923656f6d0108e2d Author: Merlijn Wajer <merlijn@wizzup.org> Date: Sun Jul 17 19:36:21 2011 +0200 Documentation: Initial libMML documentation. commit f91c9ffb0e31871c51995cf030bd811d76c8b438 Merge: f5c9690 989d077 Author: Merlijn Wajer <merlijn@wizzup.org> Date: Thu Jul 7 12:00:58 2011 +0200 Merge branch 'master' into cts-rework commit f5c9690bee157f9e8dc82a7d23c5841629e8599c Author: Merlijn Wajer <merlijn@wizzup.org> Date: Thu Jul 7 11:59:15 2011 +0200 Finder: More rework and cleanups. commit 79021409d05c24da797f73299744e588effd381c Author: Merlijn Wajer <merlijn@wizzup.org> Date: Wed Jul 6 21:34:03 2011 +0200 Finder: CTS 2 fix. commit cda571dcb0a3f3f755a63978d07f2a25f83861a7 Author: Merlijn Wajer <merlijn@wizzup.org> Date: Wed Jul 6 21:06:17 2011 +0200 Finder: Remote tolerance param. Cleanups. commit 733a8cbf320ca29f1edf60b9e29f1ae5c0d68b67 Author: Merlijn Wajer <merlijn@wizzup.org> Date: Wed Jul 6 20:39:44 2011 +0200 Finder: More fixes. :-) commit e6b005b61f0a4c223d0e8c1f109d28aa48c0ad17 Author: Merlijn Wajer <merlijn@wizzup.org> Date: Wed Jul 6 18:34:49 2011 +0200 Finder: CTS-rework fixes. commit 6f896b56a292098a1aef2ddb138ea65ce96ec6a3 Author: Merlijn Wajer <merlijn@wizzup.org> Date: Wed Jul 6 18:15:33 2011 +0200 Finder: Start CTS rework. commit a63039914878e2eb40ff21a9c76f757b6e785716 Author: Merlijn Wajer <merlijn@wizzup.org> Date: Wed Jul 6 13:01:22 2011 +0200 Small TODO update. commit 0e6bf83a5cf5fa9d319fe10276f3f2291025b543 Merge: f19fd6b f2873b1 Author: Merlijn Wajer <merlijn@wizzup.org> Date: Wed Jul 6 12:59:09 2011 +0200 Merge branch 'master' into cts-rework commit f19fd6bf8d3589c196d063e1ff4962994606af55 Author: Merlijn Wajer <merlijn@wizzup.org> Date: Sun Jul 3 20:42:14 2011 +0200 Simba/Doc: Add Raymond to doc. commit 451ab89db36cc9b0fa5508a56917291918a1127f Merge: 37183f5 35026bc Author: Merlijn Wajer <merlijn@wizzup.org> Date: Sat Jul 2 14:48:43 2011 +0200 Merge branch 'master' into cts-rework commit 37183f5fd0baaa46f3726ce835f009153ef611d0 Merge: cca7b05 6873e72 Author: Merlijn Wajer <merlijn@wizzup.org> Date: Tue Jun 28 22:10:02 2011 +0200 Merge branch 'master' into cts-rework commit cca7b052135c874064ae9277956a7d078a58dbaf Author: Merlijn Wajer <merlijn@wizzup.org> Date: Thu Jun 16 17:03:14 2011 +0200 Add CTS 3 to FindColorsTolerance. Conflicts: Units/MMLCore/finder.pas commit c837d9b96057a58e4cd1a1d5efa241118e1e7d7d Author: Merlijn Wajer <merlijn@wizzup.org> Date: Thu Jun 16 16:33:25 2011 +0200 CTS 3: Fix typo. commit 52db461f845694d89254c7f0ea5d5fecfc9764f7 Author: Merlijn Wajer <merlijn@wizzup.org> Date: Mon Jun 6 16:06:17 2011 +0200 CTS 3: Now implement the formula properly. commit 7a0db25416639e76234b239a854b510e2043a91b Author: Merlijn Wajer <merlijn@wizzup.org> Date: Sun Jun 5 19:44:52 2011 +0200 Add L*a*b CTS (3). commit 2e1e786d0ece69dc3e42fb92106a71dce0faf975 Author: Merlijn Wajer <merlijn@wizzup.org> Date: Thu Jun 16 15:11:17 2011 +0200 FindBitmapToleranceIn now works. commit 58ea6021cd0cee3bd54f8ce93713bedc9ff3feb4 Author: Merlijn Wajer <merlijn@wizzup.org> Date: Thu Jun 16 14:26:20 2011 +0200 CTS work. CTS 2 is still broken for bitmaps. commit 91d952d33ab9b8ddcb76bed991a1ea0c5907e084 Author: Merlijn Wajer <merlijn@wizzup.org> Date: Thu Jun 16 12:52:10 2011 +0200 CTS cleanups. commit d9836a251c3ed4a3367383b7e182c648905fabee Merge: 5bf7d8b bfc3f86 Author: Merlijn Wajer <merlijn@wizzup.org> Date: Mon Jun 13 20:44:08 2011 +0200 Merge branch 'master' into cts-rework commit 5bf7d8beeaf69133b03a3f8c04124f33dea4e24c Author: Merlijn Wajer <merlijn@wizzup.org> Date: Mon Jun 13 20:38:00 2011 +0200 Completed first CTS rework. commit 7a412d16704f270ba44674c8422e1272c8994b11 Author: Merlijn Wajer <merlijn@wizzup.org> Date: Mon Jun 13 20:21:23 2011 +0200 CTS: Cleanups. commit 14474a84ab69e15a1de3998dc01cb3053daba384 Author: Merlijn Wajer <merlijn@wizzup.org> Date: Mon Jun 13 18:16:59 2011 +0200 CTS rework for FindColorsTolerance. commit b87a123701fb192b2f31efb8896d7e661b399c32 Author: Merlijn Wajer <merlijn@wizzup.org> Date: Mon Jun 13 17:44:04 2011 +0200 More cleanups to CTS. commit 9415d0810088c37e7f0f79e2a31c7e723bd6152c Author: Merlijn Wajer <merlijn@wizzup.org> Date: Mon Jun 13 17:41:06 2011 +0200 Finder: Trying a different CTS approach.
2011-08-03 19:23:49 -04:00
procedure XYZtoCIELab(X, Y, Z: Extended; out L, a, b: Extended);
begin
X := X / 95.047;
Y := Y / 100.000;
Z := Z / 108.883;
if ( X > 0.008856 ) then
X := Power(X, 1.0/3.0)
else
X := ( 7.787 * X ) + ( 16.0 / 116.0 );
if ( Y > 0.008856 ) then
Y := Power(Y, 1.0/3.0)
else
Y := ( 7.787 * Y ) + ( 16.0 / 116.0 );
if ( Z > 0.008856 ) then
Z := Power(Z, 1.0/3.0)
else
Z := ( 7.787 * Z ) + ( 16.0 / 116.0 );
L := (116.0 * Y ) - 16.0;
a := 500.0 * ( X - Y );
b := 200.0 * ( Y - Z );
end;
procedure CIELabtoXYZ(L, a, b: Extended; out X, Y, Z: Extended);
begin
Y := ( L + 16 ) / 116.0;
X := ( a / 500.0 )+ Y;
Z := Y - ( b / 200.0 );
if ( Power(Y, 3) > 0.008856 ) then
Y := Power(Y, 3)
else
Y := ( Y - (16.0 / 116.0 )) / 7.787;
if ( Power(X, 3) > 0.008856 ) then
X := Power(X, 3)
else
X := ( X - (16.0 / 116.0) ) / 7.787;
if ( Power(Z, 3) > 0.008856 ) then
Z := Power(Z, 3)
else
Z := ( Z - (16.0 / 116.0) ) / 7.787;
X := 95.047 * X;
Y := 100.000 * Y;
Z := 108.883 * Z;
end;
end.