This is an Object Pascal implementation of monochrome X-Face encoder/decoder.
It came about because XanaNews was moving towards being a 64 bit application but the only implementation available to XanaNews was some 32 bit .OBJ files.
It was written with a portable version of FreePascal/Lazarus while on holidays, so it should be compatible with both Delphi and FreePascal.
var
LConvertedBitMap : TBitmap;
LXFace : IXFace;
LXFaceTransferOutBitmap : ITransferOutBitmapAccess;
LXFaceString: string;
begin
LXFace := TXFace.Create;
LXFaceTransferOutBitmap := TXFaceTransferOutBitmap.Create;
LXFace.UncompressXFace(LXFaceString, LXFaceTransferOutBitmap as IXFaceTransferOut);
LConvertedBitMap := TBitmap.Create;
try
LConvertedBitMap.Assign(LXFaceTransferOutBitmap.Bitmap);
// Do something with the image.
finally
LConvertedBitMap.Free;
end;
end;
function ImageToXFace(const ABitmap : TBitmap; const ATopLeft : TPoint) : string;
var
LXFace : IXFace;
LXFaceTransferIn : IXFaceTransferIn;
begin
LXFace := TXFace.Create;
LXFaceTransferIn := TXFaceTransferInGraphic.Create(ABitMap, ATopLeft);
Result := LXFace.CompressXFace(LXFaceTransferIn);
end;