diff --git a/components/rgbgraphics/example/rgbexample.lpi b/components/rgbgraphics/example/rgbexample.lpi index ab6de17a2..34b3a3b4d 100644 --- a/components/rgbgraphics/example/rgbexample.lpi +++ b/components/rgbgraphics/example/rgbexample.lpi @@ -2,12 +2,12 @@ - + - + @@ -33,14 +33,14 @@ - + - + - + @@ -48,17 +48,17 @@ - + - + - - + + @@ -70,22 +70,22 @@ - - + + - - + + - - + + @@ -96,51 +96,51 @@ - - - - + + + + - - + + - + - + - + - + - + - + @@ -154,179 +154,174 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - - - + + - - + - - - + - + - + + + - - - + + - - + - + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/components/rgbgraphics/example/rgbunit.lfm b/components/rgbgraphics/example/rgbunit.lfm index a0d552d35..98857e272 100644 --- a/components/rgbgraphics/example/rgbunit.lfm +++ b/components/rgbgraphics/example/rgbunit.lfm @@ -12,11 +12,12 @@ object FormExample: TFormExample OnCreate = FormCreate OnDestroy = FormDestroy OnPaint = FormPaint + LCLVersion = '0.9.25' object ButtonRedLine: TButton Left = 6 - Height = 26 + Height = 31 Top = 8 - Width = 89 + Width = 96 AutoSize = True BorderSpacing.InnerBorder = 4 Caption = 'Draw red line' @@ -25,7 +26,7 @@ object FormExample: TFormExample end object ButtonRotate90: TButton Left = 6 - Height = 26 + Height = 31 Top = 39 Width = 131 AutoSize = True @@ -36,9 +37,9 @@ object FormExample: TFormExample end object ButtonInvert: TButton Left = 6 - Height = 26 + Height = 31 Top = 72 - Width = 83 + Width = 92 AutoSize = True BorderSpacing.InnerBorder = 4 Caption = 'Invert colors' @@ -47,9 +48,9 @@ object FormExample: TFormExample end object ButtonReplace: TButton Left = 6 - Height = 26 + Height = 31 Top = 106 - Width = 136 + Width = 137 AutoSize = True BorderSpacing.InnerBorder = 4 Caption = 'Replace red with blue' diff --git a/components/rgbgraphics/example/rgbunit.lrs b/components/rgbgraphics/example/rgbunit.lrs index 8c0a2a822..7f7ef1898 100644 --- a/components/rgbgraphics/example/rgbunit.lrs +++ b/components/rgbgraphics/example/rgbunit.lrs @@ -5,19 +5,19 @@ LazarusResources.Add('TFormExample','FORMDATA',[ +#3#150#0#5'Width'#3#133#2#18'HorzScrollBar.Page'#3#132#2#18'VertScrollBar.Pa' +'ge'#3#1#2#13'ActiveControl'#7#13'ButtonRedLine'#7'Caption'#6#22'LazRGBGraph' +'ics Example'#12'ClientHeight'#3#2#2#11'ClientWidth'#3#133#2#8'OnCreate'#7#10 - +'FormCreate'#9'OnDestroy'#7#11'FormDestroy'#7'OnPaint'#7#9'FormPaint'#0#7'TB' - +'utton'#13'ButtonRedLine'#4'Left'#2#6#6'Height'#2#26#3'Top'#2#8#5'Width'#2'Y' - +#8'AutoSize'#9#25'BorderSpacing.InnerBorder'#2#4#7'Caption'#6#13'Draw red li' - +'ne'#7'OnClick'#7#18'ButtonRedLineClick'#8'TabOrder'#2#0#0#0#7'TButton'#14'B' - +'uttonRotate90'#4'Left'#2#6#6'Height'#2#26#3'Top'#2''''#5'Width'#3#131#0#8'A' - +'utoSize'#9#25'BorderSpacing.InnerBorder'#2#4#7'Caption'#6#19'Rotate 90 cloc' - +'kwise'#7'OnClick'#7#19'ButtonRotate90Click'#8'TabOrder'#2#1#0#0#7'TButton' - +#12'ButtonInvert'#4'Left'#2#6#6'Height'#2#26#3'Top'#2'H'#5'Width'#2'S'#8'Aut' - +'oSize'#9#25'BorderSpacing.InnerBorder'#2#4#7'Caption'#6#13'Invert colors'#7 - +'OnClick'#7#17'ButtonInvertClick'#8'TabOrder'#2#2#0#0#7'TButton'#13'ButtonRe' - +'place'#4'Left'#2#6#6'Height'#2#26#3'Top'#2'j'#5'Width'#3#136#0#8'AutoSize'#9 - +#25'BorderSpacing.InnerBorder'#2#4#7'Caption'#6#21'Replace red with blue'#7 - +'OnClick'#7#18'ButtonReplaceClick'#8'TabOrder'#2#3#0#0#18'TOpenPictureDialog' - +#17'OpenPictureDialog'#5'Title'#6#12'Open picture'#4'left'#3#211#0#3'top'#2 - +'Q'#0#0#0 + +'FormCreate'#9'OnDestroy'#7#11'FormDestroy'#7'OnPaint'#7#9'FormPaint'#10'LCL' + +'Version'#6#6'0.9.25'#0#7'TButton'#13'ButtonRedLine'#4'Left'#2#6#6'Height'#2 + +#31#3'Top'#2#8#5'Width'#2'`'#8'AutoSize'#9#25'BorderSpacing.InnerBorder'#2#4 + +#7'Caption'#6#13'Draw red line'#7'OnClick'#7#18'ButtonRedLineClick'#8'TabOrd' + +'er'#2#0#0#0#7'TButton'#14'ButtonRotate90'#4'Left'#2#6#6'Height'#2#31#3'Top' + +#2''''#5'Width'#3#131#0#8'AutoSize'#9#25'BorderSpacing.InnerBorder'#2#4#7'Ca' + +'ption'#6#19'Rotate 90 clockwise'#7'OnClick'#7#19'ButtonRotate90Click'#8'Tab' + +'Order'#2#1#0#0#7'TButton'#12'ButtonInvert'#4'Left'#2#6#6'Height'#2#31#3'Top' + +#2'H'#5'Width'#2'\'#8'AutoSize'#9#25'BorderSpacing.InnerBorder'#2#4#7'Captio' + +'n'#6#13'Invert colors'#7'OnClick'#7#17'ButtonInvertClick'#8'TabOrder'#2#2#0 + +#0#7'TButton'#13'ButtonReplace'#4'Left'#2#6#6'Height'#2#31#3'Top'#2'j'#5'Wid' + +'th'#3#137#0#8'AutoSize'#9#25'BorderSpacing.InnerBorder'#2#4#7'Caption'#6#21 + +'Replace red with blue'#7'OnClick'#7#18'ButtonReplaceClick'#8'TabOrder'#2#3#0 + +#0#18'TOpenPictureDialog'#17'OpenPictureDialog'#5'Title'#6#12'Open picture'#4 + +'left'#3#211#0#3'top'#2'Q'#0#0#0 ]); diff --git a/components/rgbgraphics/lazrgbgraphics.lpk b/components/rgbgraphics/lazrgbgraphics.lpk index f80f007f3..120ddf7e0 100644 --- a/components/rgbgraphics/lazrgbgraphics.lpk +++ b/components/rgbgraphics/lazrgbgraphics.lpk @@ -4,7 +4,6 @@ - @@ -29,8 +28,8 @@ "/> - - + + @@ -62,6 +61,11 @@ + + + + + diff --git a/components/rgbgraphics/rgbcarbonroutines.pas b/components/rgbgraphics/rgbcarbonroutines.pas index 8cd9ae330..6994a9183 100644 --- a/components/rgbgraphics/rgbcarbonroutines.pas +++ b/components/rgbgraphics/rgbcarbonroutines.pas @@ -1,6 +1,6 @@ { /*************************************************************************** - RGBGTKRoutines.pas + RGBCarbonRoutines.pas ***************************************************************************/ @@ -19,7 +19,7 @@ Author: Tom Gregorovic (_tom_@centrum.cz) Abstract: - This unit contains routines for GTK interfaces. + This unit contains routines for Carbon interface. } unit RGBCarbonRoutines; diff --git a/components/rgbgraphics/rgbgtkroutines.pas b/components/rgbgraphics/rgbgtkroutines.pas index 28ecb612e..817add38f 100644 --- a/components/rgbgraphics/rgbgtkroutines.pas +++ b/components/rgbgraphics/rgbgtkroutines.pas @@ -54,21 +54,12 @@ procedure WidgetSetDrawRGB32Bitmap(Dest: HDC; DstX, DstY: Integer; SrcX, SrcY, S var P: TPoint; begin - {$IFDEF GTK_POST_0924} P := TGtkDeviceContext(Dest).Offset; Inc(DstX, P.X); Inc(DstY, P.Y); gdk_draw_rgb_32_image(TGtkDeviceContext(Dest).Drawable, TGtkDeviceContext(Dest).GC, DstX, DstY, SrcWidth, SrcHeight, GDK_RGB_DITHER_NONE, Pguchar(Bitmap.GetPixelPtrUnsafe(SrcX, SrcY)), Bitmap.RowPixelStride shl 2); - {$ELSE} - P := GetDCOffset(TGtkDeviceContext(Dest)); - Inc(DstX, P.X); - Inc(DstY, P.Y); - gdk_draw_rgb_32_image(TDeviceContext(Dest).Drawable, TDeviceContext(Dest).GC, - DstX, DstY, SrcWidth, SrcHeight, GDK_RGB_DITHER_NONE, - Pguchar(Bitmap.GetPixelPtrUnsafe(SrcX, SrcY)), Bitmap.RowPixelStride shl 2); - {$ENDIF} end; procedure WidgetSetDrawRGB8Bitmap(Dest: HDC; DstX, DstY: Integer; SrcX, SrcY, @@ -76,21 +67,12 @@ procedure WidgetSetDrawRGB8Bitmap(Dest: HDC; DstX, DstY: Integer; SrcX, SrcY, var P: TPoint; begin - {$IFDEF GTK_POST_0924} P := TGtkDeviceContext(Dest).Offset; Inc(DstX, P.X); Inc(DstY, P.Y); gdk_draw_gray_image(TGtkDeviceContext(Dest).Drawable, TGtkDeviceContext(Dest).GC, DstX, DstY, SrcWidth, SrcHeight, GDK_RGB_DITHER_NONE, Pguchar(Bitmap.Get8PixelPtrUnsafe(SrcX, SrcY)), Bitmap.RowPixelStride); - {$ELSE} - P := GetDCOffset(TDeviceContext(Dest)); - Inc(DstX, P.X); - Inc(DstY, P.Y); - gdk_draw_gray_image(TDeviceContext(Dest).Drawable, TDeviceContext(Dest).GC, - DstX, DstY, SrcWidth, SrcHeight, GDK_RGB_DITHER_NONE, - Pguchar(Bitmap.Get8PixelPtrUnsafe(SrcX, SrcY)), Bitmap.RowPixelStride); - {$ENDIF} end; initialization diff --git a/components/rgbgraphics/rgbqtroutines.pas b/components/rgbgraphics/rgbqtroutines.pas new file mode 100644 index 000000000..c2b18267f --- /dev/null +++ b/components/rgbgraphics/rgbqtroutines.pas @@ -0,0 +1,97 @@ +{ + /*************************************************************************** + RGBQtRoutines.pas + + + ***************************************************************************/ + + ***************************************************************************** + * * + * See the file COPYING.modifiedLGPL, included in this distribution, * + * for details about the copyright. * + * * + * 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. * + * * + ***************************************************************************** + + Author: Tom Gregorovic (_tom_@centrum.cz) + + Abstract: + This unit contains routines for Qt interface. + +} +unit RGBQtRoutines; + +{$ifdef fpc} + {$mode objfpc}{$H+} +{$endif} + +interface + +uses + SysUtils, Types, LCLType, Qt4, QtObjects, Classes, + RGBTypes; + + procedure WidgetSetDrawRGB32Bitmap(Dest: HDC; DstX, DstY: Integer; SrcX, SrcY, SrcWidth, SrcHeight: Integer; + Bitmap: TRGB32BitmapCore); + procedure WidgetSetStretchDrawRGB32Bitmap(Dest: HDC; DstX, DstY, DstWidth, DstHeight: Integer; + SrcX, SrcY, SrcWidth, SrcHeight: Integer; Bitmap: TRGB32BitmapCore); + + procedure WidgetSetDrawRGB8Bitmap(Dest: HDC; DstX, DstY: Integer; SrcX, SrcY, SrcWidth, SrcHeight: Integer; + Bitmap: TRGB8BitmapCore); + +implementation + +procedure WidgetSetDrawRGB32Bitmap(Dest: HDC; DstX, DstY: Integer; SrcX, SrcY, SrcWidth, + SrcHeight: Integer; Bitmap: TRGB32BitmapCore); +begin + WidgetSetStretchDrawRGB32Bitmap(Dest, DstX, DstY, SrcWidth, SrcHeight, SrcX, SrcY, SrcWidth, SrcHeight, Bitmap); +end; + +procedure WidgetSetStretchDrawRGB32Bitmap(Dest: HDC; DstX, DstY, DstWidth, + DstHeight: Integer; SrcX, SrcY, SrcWidth, SrcHeight: Integer; + Bitmap: TRGB32BitmapCore); +var + DstQDC: TQtDeviceContext absolute Dest; + SrcRect, DstRect: TRect; + Image: TQtImage; +begin + DstRect := Bounds(DstX, DstY, DstWidth, DstHeight); + SrcRect := Bounds(SrcX, SrcY, SrcWidth, SrcHeight); + + Image := TQtImage.Create(Bitmap.Pixels, Bitmap.Width, Bitmap.Height, QImageFormat_RGB32); + try + QPainter_drawImage(DstQDC.Widget, PRect(@DstRect), Image.Handle, @SrcRect, QtAutoColor); + finally + Image.Free; + end; +end; + +procedure WidgetSetDrawRGB8Bitmap(Dest: HDC; DstX, DstY: Integer; SrcX, SrcY, + SrcWidth, SrcHeight: Integer; Bitmap: TRGB8BitmapCore); +var + DstQDC: TQtDeviceContext absolute Dest; + SrcRect, DstRect: TRect; + Image: TQtImage; + I: Integer; +begin + DstRect := Bounds(DstX, DstY, SrcWidth, SrcHeight); + SrcRect := Bounds(SrcX, SrcY, SrcWidth, SrcHeight); + + Image := TQtImage.Create(Bitmap.Pixels, Bitmap.Width, Bitmap.Height, QImageFormat_Indexed8); + try + // initialize palette + for I := 0 to 255 do + QImage_setColor(Image.Handle, I, I + I shl 8 + I shl 16 + $FF shl 24); + + QPainter_drawImage(DstQDC.Widget, PRect(@DstRect), Image.Handle, @SrcRect, QtAutoColor); + finally + Image.Free; + end; +end; + + +end. + diff --git a/components/rgbgraphics/rgbroutines.pas b/components/rgbgraphics/rgbroutines.pas index 4aa17f3d2..34cfb99f1 100644 --- a/components/rgbgraphics/rgbroutines.pas +++ b/components/rgbgraphics/rgbroutines.pas @@ -39,6 +39,9 @@ uses {$IFDEF LCLwin32} RGBWinRoutines, {$ENDIF} +{$IFDEF LCLqt} + RGBQtRoutines, +{$ENDIF} {$IFDEF LCLgtk} {$DEFINE StretchRGB32} RGBGTKRoutines, diff --git a/components/rgbgraphics/rgbtypes.pas b/components/rgbgraphics/rgbtypes.pas index 23fcfac54..abf05e06f 100644 --- a/components/rgbgraphics/rgbtypes.pas +++ b/components/rgbgraphics/rgbtypes.pas @@ -33,6 +33,9 @@ unit RGBTypes; {$ifdef LCLwin32} {$define RGB} {$endif} +{$ifdef LCLqt} + {$define RGB} +{$endif} interface