From f623c0d0c7aef9092bad388a4cadf7e34b18547f Mon Sep 17 00:00:00 2001 From: LongDirtyAnimAlf Date: Tue, 3 Jul 2018 15:05:24 +0200 Subject: [PATCH] Windows RGBA bug --- Lazarus/Windows/vfwdemo1/UConvert.pas | 32 +++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/Lazarus/Windows/vfwdemo1/UConvert.pas b/Lazarus/Windows/vfwdemo1/UConvert.pas index e5bef4b..f929fee 100644 --- a/Lazarus/Windows/vfwdemo1/UConvert.pas +++ b/Lazarus/Windows/vfwdemo1/UConvert.pas @@ -24,13 +24,21 @@ interface PARGB = ^TARGB; TARGB = packed record case Byte of - 1: (B, G, R, A: Byte); + 1: (A, R, G, B: Byte); 2: (Color: LongWord); end; - PARGBArray = ^TARGBArray; TARGBArray = array[0..0] of TARGB; + PBGRA = ^TBGRA; + TBGRA = packed record + case Byte of + 1: (B, G, R, A: Byte); + 2: (Color: LongWord); + end; + PBGRAArray = ^TBGRAArray; + TBGRAArray = array[0..0] of TBGRA; + PRGB = ^TRGB; TRGB = packed record B, G, R: Byte; @@ -52,6 +60,7 @@ interface end; function CodecToARGB(Src, Dest: Pointer; Width, Height: Integer; BitCount: Word; Codec: LongWord): Boolean; + function CodecToBGRA(Src, Dest: Pointer; Width, Height: Integer; BitCount: Word; Codec: LongWord): Boolean; function ARGBToCodec(Src, Dest: Pointer; Width, Height: Integer; BitCount: Word; Codec: LongWord): Boolean; function Conv15To32(Color: Word): LongWord; overload; @@ -93,6 +102,25 @@ function CodecToARGB(Src, Dest: Pointer; Width, Height: Integer; BitCount: Word; end; end; +function CodecToBGRA(Src, Dest: Pointer; Width, Height: Integer; BitCount: Word; Codec: LongWord): Boolean; +begin + Result:=True; + { + case Codec of + BI_RGB: case BitCount of + 16: Conv16To32(src, dest, Width, Height); + 24: Conv24To32(src, dest, Width, Height); + 32: Move(src^, dest^, Width*Height*4); + end; + UYVY: UYVYtoARGB(src, dest, Width, Height); + YUY2: YUY2toARGB(src, dest, Width, Height); + I420: I420toARGB(src, dest, Width, Height); + else + Result:=False; + end; + } +end; + function ARGBToCodec(Src, Dest: Pointer; Width, Height: Integer; BitCount: Word; Codec: LongWord): Boolean; begin Result:=True;