Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Catalog · How the catalog works
Anything · Lazarus or Delphi
Random projectRandom project

X-Face

Pascal implementation of X-Face encoder/decoder.

View on GitHub

Member rating

No ratings yet.

Sign in to rate this project.

README

X-Face

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.

Convert from string to image

pascal
var
  LConvertedBitMap : TBitmap;
  LXFace : IXFace;
  LXFaceTransferOutBitmap : ITransferOutBitmapAccess;
  LXFaceString: string;
begin
  LXFace := TXFace.Create;
  LXFaceTransferOutBitmap := TXFaceTransferOutBitmap.Create;
  LXFace.UncompressXFace(LXFaceString, LXFaceTransferOutBitmap as IXFaceTransferOut);
pascal
LConvertedBitMap := TBitmap.Create;
try
  LConvertedBitMap.Assign(LXFaceTransferOutBitmap.Bitmap);
  // Do something with the image.
finally
  LConvertedBitMap.Free;
end;
pascal
end;

Convert from image to string

pascal
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;