Adds support for RGB of depth 16 bits in GraphType in and LCL-CustomDrawn

git-svn-id: trunk@33783 -
This commit is contained in:
sekelsenmat 2011-11-25 17:12:07 +00:00
parent c2aebf3ca5
commit 1207aa33c0
3 changed files with 34 additions and 3 deletions

View File

@ -150,6 +150,9 @@ type
// don't use a contructor here, it will break compatebility with a record
procedure Init;
// 16-bits formats
procedure Init_BPP16_R5G6B5(AWidth, AHeight: integer);
// Formats in RGB order
procedure Init_BPP24_R8G8B8_BIO_TTB(AWidth, AHeight: integer);
procedure Init_BPP24_R8G8B8_BIO_TTB_UpsideDown(AWidth, AHeight: integer);
@ -574,6 +577,30 @@ begin
FillChar(Self, SizeOf(Self), 0);
end;
procedure TRawImageDescription.Init_BPP16_R5G6B5(AWidth, AHeight: integer);
begin
// setup an artificial ScanLineImage with format RGB 24 bit, 24bit depth format
FillChar(Self, SizeOf(Self), 0);
Format := ricfRGBA;
Depth := 16; // used bits per pixel
Width := AWidth;
Height := AHeight;
BitOrder := riboBitsInOrder;
ByteOrder := riboLSBFirst;
LineOrder := riloTopToBottom;
BitsPerPixel := 24; // bits per pixel. can be greater than Depth.
LineEnd := rileDWordBoundary;
RedPrec := 5; // red precision. bits for red
RedShift := 0;
GreenPrec := 6;
GreenShift := 5; // bitshift. Direction: from least to most significant
BluePrec := 5;
BlueShift:=11;
// AlphaPrec:=0;
// MaskBitsPerPixel:=0;
end;
procedure TRawImageDescription.Init_BPP24_R8G8B8_BIO_TTB(AWidth, AHeight: integer);
begin
// setup an artificial ScanLineImage with format RGB 24 bit, 24bit depth format

View File

@ -103,7 +103,7 @@ begin
engine^.height := h;
engine^.state.angle := 0;
UpdateControlLazImageAndCanvas(engine^.Image, engine^.Canvas, engine^.width, engine^.height, clfBGRA32);
UpdateControlLazImageAndCanvas(engine^.Image, engine^.Canvas, engine^.width, engine^.height, clfRGB16_R5G6B5);
engine^.Image.GetRawImage(engine^.RawImage);
engine^.Canvas.Brush.FPColor := colRed;
engine^.Canvas.Rectangle(0, 0, 100, 100);
@ -136,7 +136,8 @@ begin
glGenTextures(1, @texture);
glBindTexture(GL_TEXTURE_2D, texture);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, engine^.width, engine^.height, 0, GL_RGBA, GL_UNSIGNED_BYTE, Pointer(engine^.RawImage.Data));
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, engine^.width, engine^.height, 0,
GL_RGBA, GL_UNSIGNED_SHORT_5_6_5, Pointer(engine^.RawImage.Data));
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);

View File

@ -15,7 +15,9 @@ uses
Forms;
type
TUpdateLazImageFormat = (clfRGB24,clfRGB24UpsideDown, clfBGR24, clfBGRA32);
TUpdateLazImageFormat = (
clfRGB16_R5G6B5,
clfRGB24, clfRGB24UpsideDown, clfBGR24, clfBGRA32);
TCDWinControl = class
public
@ -54,6 +56,7 @@ begin
lRawImage.Init;
case AFormat of
clfRGB16_R5G6B5: lRawImage.Description.Init_BPP16_R5G6B5(AWidth, AHeight);
clfRGB24: lRawImage.Description.Init_BPP24_R8G8B8_BIO_TTB(AWidth, AHeight);
clfRGB24UpsideDown: lRawImage.Description.Init_BPP24_R8G8B8_BIO_TTB_UpsideDown(AWidth, AHeight);
clfBGR24: lRawImage.Description.Init_BPP24_B8G8R8_BIO_TTB(AWidth, AHeight);