From 65eac79f6276b3585af0249e43ae801d46356848 Mon Sep 17 00:00:00 2001 From: yangjixian Date: Tue, 19 Apr 2011 08:26:16 +0000 Subject: [PATCH] fixed colorpalette bugs. now it works fine. DLBitmap works fine on linux and windows now. git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@1581 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- applications/lazimageeditor/DLBitmap.pas | 14 +-- applications/lazimageeditor/colorpalette.pas | 6 +- .../lazimageeditor/lazimageeditor.lpi | 114 ++++++++++-------- .../lazimageeditor/lazimageeditor.pas | 2 +- applications/lazimageeditor/main.lfm | 8 +- applications/lazimageeditor/main.lrs | 6 +- applications/lazimageeditor/main.pas | 10 +- 7 files changed, 84 insertions(+), 76 deletions(-) diff --git a/applications/lazimageeditor/DLBitmap.pas b/applications/lazimageeditor/DLBitmap.pas index c6602dc4b..e31c5d462 100644 --- a/applications/lazimageeditor/DLBitmap.pas +++ b/applications/lazimageeditor/DLBitmap.pas @@ -16,7 +16,11 @@ type rgbtAlpha: byte; end; PRGBATriple = ^TRGBATriple; + {$ifdef MSWINDOWS} + TRGBATriple = tagRGBTRIPLE; + {$else} TRGBATriple = tagRGBATRIPLE; + {$endif} PRGBATripleArray = ^TRGBATripleArray; TRGBATripleArray = array[word] of TRGBATriple; @@ -87,11 +91,7 @@ begin Bmp := TDLBitmap.Create; Bmp.Width := aBitmap.Height; Bmp.Height := aBitmap.Width; - {$ifdef MSWINDOWS} - Bmp.PixelFormat := pf32bit; - {$else} Bmp.PixelFormat := pf24bit; - {$endif} IntfImg1 := TLazIntfImage.Create(0, 0); IntfImg1.LoadFromBitmap(Bmp.Handle, Bmp.MaskHandle); IntfImg2 := TLazIntfImage.Create(0, 0); @@ -351,8 +351,6 @@ var begin Result := False; try - if BitmapIn.PixelFormat <> pf24bit then - Exit; with BitmapOut do begin Width := BitmapIn.Width; @@ -433,11 +431,7 @@ end; constructor TDLBitmap.Create; begin inherited; - {$ifdef MSWINDOWS} - PixelFormat := pf32bit; - {$else} PixelFormat := pf24bit; - {$endif} FIntfImgA := TLazIntfImage.Create(0, 0); end; diff --git a/applications/lazimageeditor/colorpalette.pas b/applications/lazimageeditor/colorpalette.pas index 3bad4bf0d..9c53a1d51 100644 --- a/applications/lazimageeditor/colorpalette.pas +++ b/applications/lazimageeditor/colorpalette.pas @@ -65,6 +65,7 @@ type FOnColorPick: TColorMouseEvent; FRows: Integer; FColors: TList; + MX, MY: integer; function GetColors(Index: Integer): TColor; procedure SetButtonHeight(const AValue: Integer); procedure SetButtonWidth(const AValue: Integer); @@ -180,6 +181,9 @@ procedure TCustomColorPalette.MouseDown(Button: TMouseButton; begin inherited; + MX := X; + MY := Y; + X := X div FButtonWidth; Y := Y div FButtonHeight; @@ -197,7 +201,7 @@ end; procedure TCustomColorPalette.MouseUp(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin - if PickedColor <> clNone then + if (PickedColor <> clNone) and (MX = X) and (MY = Y) then ColorPick(PickedColor, PickShift); inherited; end; diff --git a/applications/lazimageeditor/lazimageeditor.lpi b/applications/lazimageeditor/lazimageeditor.lpi index ba01f5dc9..7495191e8 100644 --- a/applications/lazimageeditor/lazimageeditor.lpi +++ b/applications/lazimageeditor/lazimageeditor.lpi @@ -41,15 +41,17 @@ - + + - - + + + @@ -58,11 +60,10 @@ - - - + + @@ -70,9 +71,9 @@ - + - + @@ -177,7 +178,7 @@ - + @@ -243,9 +244,9 @@ - + - + @@ -276,9 +277,9 @@ - + - + @@ -302,10 +303,10 @@ - + - - + + @@ -362,7 +363,7 @@ - + @@ -377,127 +378,138 @@ + + + + + + + + + + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - - + + - - + + - - + + - - + + - + - + - + - + - + - + diff --git a/applications/lazimageeditor/lazimageeditor.pas b/applications/lazimageeditor/lazimageeditor.pas index a339db360..e4aec2694 100644 --- a/applications/lazimageeditor/lazimageeditor.pas +++ b/applications/lazimageeditor/lazimageeditor.pas @@ -8,7 +8,7 @@ uses {$ENDIF}{$ENDIF} Interfaces, // this includes the LCL widgetset Preview, Forms, Main, PictureManager, PictureCtrls, Test, - NewDialog, ResizeDialog, ResizePaperDialog, PictureDialog, AboutDialog, LazColorPalette; + NewDialog, ResizeDialog, ResizePaperDialog, PictureDialog, AboutDialog; {$R *.res} diff --git a/applications/lazimageeditor/main.lfm b/applications/lazimageeditor/main.lfm index a32ff5d2d..17aef92ab 100644 --- a/applications/lazimageeditor/main.lfm +++ b/applications/lazimageeditor/main.lfm @@ -1,7 +1,7 @@ object MainForm: TMainForm - Left = 260 + Left = 180 Height = 666 - Top = 147 + Top = 135 Width = 905 Caption = 'Lazarus Image Editor' ClientHeight = 644 @@ -1292,9 +1292,9 @@ TabOrder = 5 object checkFuzzy: TCheckBox Left = 4 - Height = 19 + Height = 23 Top = 9 - Width = 20 + Width = 24 OnChange = checkFuzzyChange TabOrder = 0 end diff --git a/applications/lazimageeditor/main.lrs b/applications/lazimageeditor/main.lrs index 8e67835a3..f3ae13c09 100644 --- a/applications/lazimageeditor/main.lrs +++ b/applications/lazimageeditor/main.lrs @@ -1,8 +1,8 @@ { This is an automatically generated lazarus resource file } LazarusResources.Add('TMainForm','FORMDATA',[ - 'TPF0'#9'TMainForm'#8'MainForm'#4'Left'#3#4#1#6'Height'#3#154#2#3'Top'#3#147#0 - +#5'Width'#3#137#3#7'Caption'#6#20'Lazarus Image Editor'#12'ClientHeight'#3 + 'TPF0'#9'TMainForm'#8'MainForm'#4'Left'#3#180#0#6'Height'#3#154#2#3'Top'#3#135 + +#0#5'Width'#3#137#3#7'Caption'#6#20'Lazarus Image Editor'#12'ClientHeight'#3 +#132#2#11'ClientWidth'#3#137#3#12'Font.CharSet'#7#14'GB2312_CHARSET'#11'Font' +'.Height'#2#243#9'Font.Name'#6#12#229#190#174#232#189#175#233#155#133#233#187 +#145#10'Font.Pitch'#7#10'fpVariable'#12'Font.Quality'#7#7'fqDraft'#4'Menu'#7 @@ -733,7 +733,7 @@ LazarusResources.Add('TMainForm','FORMDATA',[ +'rentColor'#8#0#0#6'TPanel'#15'PanelTolerance2'#4'Left'#3#134#2#6'Height'#2 +'"'#3'Top'#2#0#5'Width'#2#30#5'Align'#7#6'alLeft'#10'BevelOuter'#7#6'bvNone' +#12'ClientHeight'#2'"'#11'ClientWidth'#2#30#8'TabOrder'#2#5#0#9'TCheckBox'#10 - +'checkFuzzy'#4'Left'#2#4#6'Height'#2#19#3'Top'#2#9#5'Width'#2#20#8'OnChange' + +'checkFuzzy'#4'Left'#2#4#6'Height'#2#23#3'Top'#2#9#5'Width'#2#24#8'OnChange' +#7#16'checkFuzzyChange'#8'TabOrder'#2#0#0#0#0#0#0#6'TPanel'#13'PanelPictures' +#4'Left'#2'('#6'Height'#3#5#2#3'Top'#2'i'#5'Width'#3#22#3#5'Align'#7#8'alCli' +'ent'#10'BevelOuter'#7#9'bvLowered'#8'TabOrder'#2#3#0#0#9'TMainMenu'#8'MainM' diff --git a/applications/lazimageeditor/main.pas b/applications/lazimageeditor/main.pas index 379984cd0..71f08dd5d 100644 --- a/applications/lazimageeditor/main.pas +++ b/applications/lazimageeditor/main.pas @@ -286,7 +286,6 @@ type procedure ViewShowPreviewExecute(Sender: TObject); private Pictures: TPictureManager; - CurrentPaletteColor: TColor; function GetActivePicture: TPictureBitmap; function GetActivePictureEdit: TPictureEdit; function GetActivePicturePage: TPicturePage; @@ -722,7 +721,6 @@ begin if ssMiddle in Shift then PaperColor := AColor; end; - CurrentPaletteColor := AColor; end; procedure TMainForm.PanelFillDblClick(Sender: TObject); @@ -765,13 +763,13 @@ begin Exit; if Source is TColorPalette then begin -// TPanel(Sender).Color:=CurrentPaletteColor; + TPanel(Sender).Color:=Palette.PickedColor; if Sender = PanelPaper then - ActivePictureEdit.PaperColor := CurrentPaletteColor; + ActivePictureEdit.PaperColor := Palette.PickedColor; if Sender = PanelFill then - ActivePictureEdit.FillColor := CurrentPaletteColor; + ActivePictureEdit.FillColor := Palette.PickedColor; if Sender = PanelOutline then - ActivePictureEdit.OutlineColor := CurrentPaletteColor; + ActivePictureEdit.OutlineColor := Palette.PickedColor; end; end;