mirror of
https://github.com/moparisthebest/Simba
synced 2024-11-21 08:45:06 -05:00
Forgot to add windowutil. :)
git-svn-id: http://www.villavu.com/repositories/merlijn/mufasa@4 3f818213-9676-44b0-a9b4-5e4c4e03d09d
This commit is contained in:
parent
3a3390f8a5
commit
65f6b01bc4
68
Units/MMLCore/windowutil.pas
Normal file
68
Units/MMLCore/windowutil.pas
Normal file
@ -0,0 +1,68 @@
|
||||
unit windowutil;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils
|
||||
{$IFDEF LINUX},
|
||||
x, xlib, // For X* stuff.
|
||||
GraphType // For TRawImage
|
||||
{$ENDIF};
|
||||
|
||||
{$IFDEF LINUX}
|
||||
Procedure XImageToRawImage(XImg: PXImage; Var RawImage: TRawImage);
|
||||
{$ENDIF}
|
||||
|
||||
implementation
|
||||
|
||||
{$IFDEF LINUX}
|
||||
Procedure XImageToRawImage(XImg: PXImage; Var RawImage: TRawImage);
|
||||
Begin
|
||||
RawImage.Init; { Calls raw.Description.Init as well }
|
||||
|
||||
RawImage.Description.PaletteColorCount:=0;
|
||||
RawImage.Description.MaskBitsPerPixel:=0;
|
||||
RawImage.Description.Width := XImg^.width;
|
||||
RawImage.Description.Height:= XImg^.height;
|
||||
|
||||
RawImage.Description.Format := ricfRGBA;
|
||||
|
||||
if XImg^.byte_order = LSBFirst then
|
||||
RawImage.Description.ByteOrder := riboLSBFirst
|
||||
else
|
||||
RawImage.Description.ByteOrder:= riboMSBFirst;
|
||||
|
||||
RawImage.Description.BitOrder:= riboBitsInOrder; // should be fine
|
||||
|
||||
RawImage.Description.Depth:=XImg^.depth;
|
||||
|
||||
RawImage.Description.BitsPerPixel:=XImg^.bits_per_pixel;
|
||||
|
||||
RawImage.Description.LineOrder:=riloTopToBottom;
|
||||
|
||||
RawImage.Description.LineEnd := rileDWordBoundary;
|
||||
|
||||
RawImage.Description.RedPrec := 8;
|
||||
RawImage.Description.GreenPrec:= 8;
|
||||
RawImage.Description.BluePrec:= 8;
|
||||
RawImage.Description.AlphaPrec:=0;
|
||||
|
||||
|
||||
// Can be adjusted to the XImage RedMask, etc.
|
||||
// For now I just assume the tester uses BGR.
|
||||
RawImage.Description.RedShift:=16;
|
||||
RawImage.Description.GreenShift:=8;
|
||||
RawImage.Description.BlueShift:=0;
|
||||
|
||||
RawImage.DataSize := RawImage.Description.Width * RawImage.Description.Height
|
||||
* (RawImage.Description.bitsperpixel shr 3);
|
||||
//RawImage.DataSize := RawImage.Description.Height * RawImage.Description.BitsPerLine;
|
||||
RawImage.Data := PByte(XImg^.data);
|
||||
|
||||
End;
|
||||
{$ENDIF}
|
||||
|
||||
end.
|
||||
|
Loading…
Reference in New Issue
Block a user