From: Florent O. <ou...@us...> - 2005-01-02 16:56:50
|
Update of /cvsroot/jvcl/dev/JVCL3/run In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11079/JVCL3/run Modified Files: JvFullColorSpaces.pas Log Message: Correcting the issue 2440 (http://homepages.borland.com/jedi/issuetracker/view.php?id=2440#addbugnote). TJvDEFColorSpace uses the jedo constants to get color pretty names. 4 colors spaces (YUV, YIQ, YCC, XYZ) will soon be modified to have a matrix transformation (lossless conversions). Index: JvFullColorSpaces.pas =================================================================== RCS file: /cvsroot/jvcl/dev/JVCL3/run/JvFullColorSpaces.pas,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** JvFullColorSpaces.pas 29 Dec 2004 23:15:36 -0000 1.7 --- JvFullColorSpaces.pas 2 Jan 2005 16:56:38 -0000 1.8 *************** *** 128,131 **** --- 128,153 ---- end; + {TJvColorConversionMatrix = array[0..3,0..3] of Extended; // OpenGL and D3D style matrix + PJvColorConversionMatrix = ^TJvColorConversionMatrix; + TJvMatrixType = (mtFromRGB, mtToRGB); + + TJvMatrixColorSpace = class(TJvColorSpace) + protected + FToRGBMatrix, + FFromRGBMatrix: TJvColorConversionMatrix; + public + constructor Create(ColorID: TJvFullColorSpaceID; AMatrix: PJvColorConversionMatrix; + MatrixType: TJvMatrixType); reintroduce; + destructor Destroy; override; + function ConvertToID(AFullColor: TJvFullColor; NewID: TJvFullColorSpaceID; // + RGBToNewIDMatrix: PJvColorConversionMatrix): TJvFullColor; // use a call with pointer argument + function ConvertFromID(AFullColor: TJvFullColor; OldID: TJvFullColorSpaceID; // because a matrix is 160 Bytes !!! + OldIDToRGBMatrix: PJvColorConversionMatrix): TJvFullColor; // /!\ not on the stack /!\ + function ConvertFromColor(AColor: TColor): TColor; override; // + function ConvertToColor(AColor: TJvFullColor): TColor; override; + function GetToRGBMatrix: PJvColorConversionMatrix; + function GetFromRGBMatrix: PJvColorConversionMatrix; + end;} + TJvRGBColorSpace = class(TJvColorSpace) protected *************** *** 322,328 **** var GlobalColorSpaceManager: TJvColorSpaceManager = nil; - {$IFDEF COMPILER6_UP} - GlobalPrettyNameStrings: TStrings = nil; - {$ENDIF COMPILER6_UP} const --- 344,347 ---- *************** *** 403,546 **** end; ! // (outchy) Hook of TColorBox to have access to color's pretty names. ! // Shame on me but that's the only way to access ColorToPrettyName array in the ! // ExtCtrls unit. Thanks Borland. ! ! {$IFDEF COMPILER6_UP} ! type ! TJvHookColorBox = class (TCustomColorBox) ! protected ! function GetItemsClass: TCustomComboBoxStringsClass; override; ! procedure DestroyWindowHandle; override; ! public ! constructor Create; reintroduce; ! procedure CreateWnd; override; ! procedure DestroyWnd; override; ! end; ! ! TJvHookComboBoxStrings = class (TCustomComboBoxStrings) ! protected ! function GetCount: Integer; override; ! public ! procedure Clear; override; ! function AddObject(const S: string; AObject: TObject): Integer; override; ! end; ! ! function PrettyNameStrings: TStrings; var ! AHookColorBox:TJvHookColorBox; begin ! if (GlobalPrettyNameStrings = nil) then begin ! GlobalPrettyNameStrings := TStringList.Create; ! AHookColorBox:=TJvHookColorBox.Create; ! try ! AHookColorBox.CreateWnd; ! AHookColorBox.PopulateList; ! finally ! AHookColorBox.Free; ! end; end; - - Result := GlobalPrettyNameStrings; - end; - {$ENDIF COMPILER6_UP} - - function ColorToPrettyName(Value: TColor): string; - {$IFDEF COMPILER6_UP} - var - AIndex: Integer; - begin - AIndex := PrettyNameStrings.IndexOfObject(TObject(Value)); - if AIndex <> -1 then - Result := PrettyNameStrings.Strings[AIndex] - else - Result := ColorToString(Value); - end; - {$ELSE COMPILER6_UP} - begin Result := ColorToString(Value); end; - {$ENDIF COMPILER6_UP} function PrettyNameToColor(Value: string): TColor; - {$IFDEF COMPILER6_UP} - var - AIndex: Integer; - TempResult: Longint; - begin - AIndex := PrettyNameStrings.IndexOf(Value); - if AIndex <> -1 then - Result := TColor(PrettyNameStrings.Objects[AIndex]) - else - if IdentToColor(Value,TempResult) then - Result := TempResult - else - Result := clNone; - end; - {$ELSE COMPILER6_UP} var ! TempResult: Longint; begin ! if IdentToColor(Value,TempResult) then ! Result := TempResult else Result := clNone; end; - {$ENDIF COMPILER6_UP} - - - {$IFDEF COMPILER6_UP} - //=== { TJvHookColorBox } ==================================================== - - constructor TJvHookColorBox.Create; - begin - inherited Create(nil); - Style := [cbStandardColors, cbExtendedColors, cbSystemColors, cbIncludeNone, - cbIncludeDefault, cbPrettyNames]; - end; - - procedure TJvHookColorBox.DestroyWnd; - begin - // delete the dummy handle - WindowHandle := 0; - end; - - procedure TJvHookColorBox.DestroyWindowHandle; - begin - // delete the dummy handle - WindowHandle := 0; - end; - - function TJvHookColorBox.GetItemsClass: TCustomComboBoxStringsClass; - begin - Result:=TJvHookComboBoxStrings; - end; - - procedure TJvHookColorBox.CreateWnd; - begin - // create a dummy handle so HandleAllocated will return True - WindowHandle := 1; - end; - - //=== { TJvHookComboBoxStrings } ============================================= - - procedure TJvHookComboBoxStrings.Clear; - begin - PrettyNameStrings.Clear; - end; - - function TJvHookComboBoxStrings.AddObject(const S: string; - AObject: TObject): Integer; - begin - Result := PrettyNameStrings.AddObject(S,AObject); - end; - - function TJvHookComboBoxStrings.GetCount: Integer; - begin - Result := PrettyNameStrings.Count; - end; - - {$ENDIF COMPILER6_UP} //=== { TJvColorSpace } ====================================================== --- 422,466 ---- end; ! function ColorToPrettyName(Value: TColor): string; var ! Index: Integer; begin ! for Index := Low(ColorValues) to High(ColorValues) do ! if Value = ColorValues[Index].Value then begin ! Result := ColorValues[Index].Description; ! Exit; ! end; ! for Index := Low(SysColorValues) to High(SysColorValues) do ! if Value = SysColorValues[Index].Value then ! begin ! Result := SysColorValues[Index].Description; ! Exit; end; Result := ColorToString(Value); end; function PrettyNameToColor(Value: string): TColor; var ! Index: Integer; ! ColorResult: Integer; begin ! for Index := Low(ColorValues) to High(ColorValues) do ! if CompareText(Value,ColorValues[Index].Description) = 0 then ! begin ! Result := ColorValues[Index].Value; ! Exit; ! end; ! for Index := Low(SysColorValues) to High(SysColorValues) do ! if CompareText(Value,SysColorValues[Index].Description) = 0 then ! begin ! Result := SysColorValues[Index].Value; ! Exit; ! end; ! if IdentToColor(Value,ColorResult) then ! Result := ColorResult else Result := clNone; end; //=== { TJvColorSpace } ====================================================== *************** *** 1738,1742 **** while FColorSpaceList.Remove(AColorSpace) >= 0 do ; ! end; {$IFDEF UNITVERSIONING} --- 1658,1662 ---- while FColorSpaceList.Remove(AColorSpace) >= 0 do ; ! end; {$IFDEF UNITVERSIONING} *************** *** 1757,1764 **** finalization FreeAndNil(GlobalColorSpaceManager); - {$IFDEF COMPILER6_UP} - FreeAndNil(GlobalPrettyNameStrings); - {$ENDIF COMPILER6_UP} - {$IFDEF UNITVERSIONING} UnregisterUnitVersion(HInstance); --- 1677,1680 ---- |