implemented 16bit rawimages for gtk

git-svn-id: trunk@4364 -
This commit is contained in:
mattias 2003-07-04 08:54:53 +00:00
parent 6f157b0853
commit b65277e832
4 changed files with 95 additions and 70 deletions

View File

@ -541,7 +541,7 @@ type
procedure Chord(x,y,width,height,SX,SY,EX,EY : Integer); procedure Chord(x,y,width,height,SX,SY,EX,EY : Integer);
Procedure CopyRect(const Dest : TRect; Canvas : TCanvas; const Source : TRect); Procedure CopyRect(const Dest : TRect; Canvas : TCanvas; const Source : TRect);
Procedure Draw(X,Y: Integer; Graphic : TGraphic); Procedure Draw(X,Y: Integer; Graphic : TGraphic);
procedure StretchDraw(const Rect: TRect; Graphic: TGraphic); procedure StretchDraw(const ARect: TRect; Graphic: TGraphic);
procedure Ellipse(const ARect: TRect); procedure Ellipse(const ARect: TRect);
procedure Ellipse(x1, y1, x2, y2: Integer); procedure Ellipse(x1, y1, x2, y2: Integer);
Procedure FillRect(const ARect : TRect); Procedure FillRect(const ARect : TRect);
@ -1028,6 +1028,9 @@ end.
{ ============================================================================= { =============================================================================
$Log$ $Log$
Revision 1.77 2003/07/04 08:54:53 mattias
implemented 16bit rawimages for gtk
Revision 1.76 2003/07/01 15:37:03 mattias Revision 1.76 2003/07/01 15:37:03 mattias
fixed exception handling fixed exception handling

View File

@ -40,12 +40,12 @@ end;
{-----------------------------------------------} {-----------------------------------------------}
{-- TCanvas.StretchDraw --} {-- TCanvas.StretchDraw --}
{-----------------------------------------------} {-----------------------------------------------}
procedure TCanvas.StretchDraw(const Rect: TRect; Graphic: TGraphic); procedure TCanvas.StretchDraw(const ARect: TRect; Graphic: TGraphic);
begin begin
if Assigned(Graphic) then if Assigned(Graphic) then
begin begin
RequiredState([csHandleValid, csPenValid]); RequiredState([csHandleValid, csPenValid]);
Graphic.Draw(Self, Rect); Graphic.Draw(Self, ARect);
end; end;
end; end;
@ -1216,6 +1216,9 @@ end;
{ ============================================================================= { =============================================================================
$Log$ $Log$
Revision 1.50 2003/07/04 08:54:53 mattias
implemented 16bit rawimages for gtk
Revision 1.49 2003/06/30 10:09:46 mattias Revision 1.49 2003/06/30 10:09:46 mattias
fixed Get/SetPixel for DC without widget fixed Get/SetPixel for DC without widget

View File

@ -1885,7 +1885,7 @@ begin
Desc^.ColorCount:=0; Desc^.ColorCount:=0;
// BitsPerPixel // BitsPerPixel
case Desc^.Depth of case Desc^.Depth of
0..8: Desc^.BitsPerPixel:=8; 0..8: Desc^.BitsPerPixel:=Desc^.Depth;
9..16: Desc^.BitsPerPixel:=16; 9..16: Desc^.BitsPerPixel:=16;
17..32: Desc^.BitsPerPixel:=32; 17..32: Desc^.BitsPerPixel:=32;
else Desc^.BitsPerPixel:=64; else Desc^.BitsPerPixel:=64;
@ -1893,8 +1893,7 @@ begin
// LineEnd // LineEnd
case Desc^.Depth of case Desc^.Depth of
0..8: Desc^.LineEnd:=rileByteBoundary; 0..8: Desc^.LineEnd:=rileByteBoundary;
9..16: Desc^.LineEnd:=rileWordBoundary; 9..32: Desc^.LineEnd:=rileDWordBoundary;
17..32: Desc^.LineEnd:=rileDWordBoundary;
else Desc^.LineEnd:=rileQWordBoundary; else Desc^.LineEnd:=rileQWordBoundary;
end; end;
// Precisions and Shifts // Precisions and Shifts
@ -1909,7 +1908,7 @@ begin
Desc^.AlphaShift:=0; Desc^.AlphaShift:=0;
// AlphaBitsPerPixel and AlphaLineEnd // AlphaBitsPerPixel and AlphaLineEnd
Desc^.AlphaBitsPerPixel:=Desc^.AlphaPrec; Desc^.AlphaBitsPerPixel:=Desc^.AlphaPrec;
Desc^.AlphaLineEnd:=rileDWordBoundary; Desc^.AlphaLineEnd:=rileByteBoundary;
with Desc^ do begin with Desc^ do begin
writeln('TgtkObject.GetDeviceRawImageDescription A ', writeln('TgtkObject.GetDeviceRawImageDescription A ',
@ -7882,6 +7881,9 @@ end;
{ ============================================================================= { =============================================================================
$Log$ $Log$
Revision 1.390 2003/07/04 08:54:53 mattias
implemented 16bit rawimages for gtk
Revision 1.389 2003/07/03 18:10:55 mattias Revision 1.389 2003/07/03 18:10:55 mattias
added fontdialog options to win32 intf from Wojciech Malinowski added fontdialog options to win32 intf from Wojciech Malinowski

View File

@ -850,77 +850,91 @@ begin
Result:=false; Result:=false;
Bitmap:=0; Bitmap:=0;
MaskBitmap:=0; MaskBitmap:=0;
if (RawImage.Description.Width=0) or (RawImage.Description.Height=0) then if (RawImage.Description.Width=0) or (RawImage.Description.Height=0) then
exit; exit;
writeln('TgtkObject.CreateBitmapFromRawImage A ', try
' Depth=',RawImage.Description.Depth, writeln('TgtkObject.CreateBitmapFromRawImage A ',
' Width=',RawImage.Description.Width, ' Depth=',RawImage.Description.Depth,
' Height=',RawImage.Description.Height, ' Width=',RawImage.Description.Width,
' Data=',HexStr(Cardinal(RawImage.Data),8), ' Height=',RawImage.Description.Height,
' DataSize=',RawImage.DataSize, ' Data=',HexStr(Cardinal(RawImage.Data),8),
' Mask=',HexStr(Cardinal(RawImage.Mask),8), ' DataSize=',RawImage.DataSize,
' MaskSize=',RawImage.MaskSize, ' Mask=',HexStr(Cardinal(RawImage.Mask),8),
' Palette=',HexStr(Cardinal(RawImage.Palette),8), ' MaskSize=',RawImage.MaskSize,
' PaletteSize=',RawImage.PaletteSize, ' Palette=',HexStr(Cardinal(RawImage.Palette),8),
''); ' PaletteSize=',RawImage.PaletteSize,
' BitsPerPixel=',RawImage.Description.BitsPerPixel,
// ToDo: check description '');
DefGdkWindow := nil; // ToDo: check description
GdiObject := NewGDIObject(gdiBitmap);
GdiObject^.GDIBitmapType := gbPixmap; DefGdkWindow := nil;
GdiObject := NewGDIObject(gdiBitmap);
GdiObject^.GDIBitmapType := gbPixmap;
if RawImage.Data<>nil then begin
{ The gdk_pixmap_create_from_data seems to be buggy.
It only creates pixmaps of Depth 1
gdk_pixmap_create_from_data(DefGdkWindow,PGChar(RawImage.Data),
RawImage.Description.Width, RawImage.Description.Height,
RawImage.Description.Depth, @fg,@bg);}
ImgData:=PDWord(RawImage.Data);
ImgDataSize:=RawImage.DataSize;
ImgWidth:=RawImage.Description.Width; ImgWidth:=RawImage.Description.Width;
ImgHeight:=RawImage.Description.Height; ImgHeight:=RawImage.Description.Height;
ImgDepth:=RawImage.Description.Depth; if RawImage.Data<>nil then begin
GdiObject^.GDIPixmapObject := { The gdk_pixmap_create_from_data seems to be buggy.
gdk_pixmap_new(DefGdkWindow,ImgWidth,imgHeight,ImgDepth); It only creates pixmaps of Depth 1
GDkWindow:=PGdkWindow(GdiObject^.GDIPixmapObject); gdk_pixmap_create_from_data(DefGdkWindow,PGChar(RawImage.Data),
RawImage.Description.Width, RawImage.Description.Height,
RawImage.Description.Depth, @fg,@bg);}
ImgData:=PDWord(RawImage.Data);
ImgDataSize:=RawImage.DataSize;
ImgDepth:=RawImage.Description.Depth;
GdiObject^.GDIPixmapObject :=
gdk_pixmap_new(DefGdkWindow,ImgWidth,ImgHeight,ImgDepth);
GDkWindow:=PGdkWindow(GdiObject^.GDIPixmapObject);
Visual:=gdk_visual_get_best_with_depth(ImgDepth); Visual:=gdk_visual_get_best_with_depth(ImgDepth);
GdkImage:=gdk_image_new(GDK_IMAGE_FASTEST,Visual,ImgWidth,ImgHeight); GdkImage:=gdk_image_new(GDK_IMAGE_FASTEST,Visual,ImgWidth,ImgHeight);
if ImgDataSize<>GdkImage^.bpl*ImgHeight then writeln('TgtkObject.CreateBitmapFromRawImage GdkImage: ',
RaiseGDBException('TgtkObject.CreateBitmapFromRawImage Incompatible DataSize'); ' BytesPerLine=',GdkImage^.bpl,
System.Move(ImgData^,GdkImage^.mem^,ImgDataSize); ' BytesPerPixel=',GdkImage^.bpp,
{for y:=0 to ImgHeight-1 do begin ' ByteOrder=',GdkImage^.byte_order,
for x:=0 to ImgWidth-1 do begin '');
gdk_image_put_pixel(GdkImage,X,Y,ImgData[X+Y*ImgWidth]); if (RawImage.Description.BitsPerPixel<>(GdkImage^.bpp shl 3)) then
end; RaiseGDBException('TgtkObject.CreateBitmapFromRawImage Incompatible BitsPerPixel');
end;} if (ImgDataSize<>GdkImage^.bpl*ImgHeight) then
GC:=gdk_gc_new(GDkWindow); RaiseGDBException('TgtkObject.CreateBitmapFromRawImage Incompatible DataSize');
gdk_draw_image(PGDKDrawable(GdiObject^.GDIPixmapObject),GC, System.Move(ImgData^,GdkImage^.mem^,ImgDataSize);
GdkImage,0,0,0,0,ImgWidth,ImgHeight); {for y:=0 to ImgHeight-1 do begin
gdk_gc_unref(GC); for x:=0 to ImgWidth-1 do begin
gdk_image_destroy(GdkImage); gdk_image_put_pixel(GdkImage,X,Y,ImgData[X+Y*ImgWidth]);
end else end;
GdiObject^.GDIPixmapObject := end;}
gdk_pixmap_new(DefGdkWindow, GC:=gdk_gc_new(GDkWindow);
RawImage.Description.Width, RawImage.Description.Height, gdk_draw_image(PGDKDrawable(GdiObject^.GDIPixmapObject),GC,
RawImage.Description.Depth); GdkImage,0,0,0,0,ImgWidth,ImgHeight);
GdiObject^.Visual := gdk_window_get_visual(GdiObject^.GDIPixmapObject); gdk_gc_unref(GC);
Bitmap:=HBITMAP(GdiObject); gdk_image_destroy(GdkImage);
end else
If (RawImage.Mask<>nil) then begin GdiObject^.GDIPixmapObject :=
GdiObject := NewGDIObject(gdiBitmap); gdk_pixmap_new(DefGdkWindow,
GdiObject^.GDIBitmapType := gbBitmap; RawImage.Description.Width, RawImage.Description.Height,
GdiObject^.GDIBitmapObject := RawImage.Description.Depth);
gdk_bitmap_create_from_data(DefGdkWindow,PGChar(RawImage.Mask),
RawImage.Description.Width, RawImage.Description.Height);
GdiObject^.Visual := gdk_window_get_visual(GdiObject^.GDIPixmapObject); GdiObject^.Visual := gdk_window_get_visual(GdiObject^.GDIPixmapObject);
MaskBitmap:=HBITMAP(GdiObject); Bitmap:=HBITMAP(GdiObject);
// mask
If (RawImage.Mask<>nil) then begin
GdiObject^.GDIBitmapMaskObject :=
gdk_bitmap_create_from_data(DefGdkWindow,PGChar(RawImage.Mask),
RawImage.Description.Width, RawImage.Description.Height);
end;
Result:=true;
finally
if not Result then begin
if Bitmap<>0 then DeleteObject(Bitmap);
Bitmap:=0;
if MaskBitmap<>0 then DeleteObject(MaskBitmap);
MaskBitmap:=0;
end;
end; end;
Result:=true;
end; end;
{------------------------------------------------------------------------------ {------------------------------------------------------------------------------
@ -8550,6 +8564,9 @@ end;
{ ============================================================================= { =============================================================================
$Log$ $Log$
Revision 1.258 2003/07/04 08:54:53 mattias
implemented 16bit rawimages for gtk
Revision 1.257 2003/07/03 18:10:55 mattias Revision 1.257 2003/07/03 18:10:55 mattias
added fontdialog options to win32 intf from Wojciech Malinowski added fontdialog options to win32 intf from Wojciech Malinowski