I am using AsphyreSphinx framework to draw 2D DirectX scene on form canvas. Since their forums are closed, I have to ask here for help. I am drawing image to form canvas like this:
DXCore.Canvas.UseImage(TableResources.TableImage, TexFull4);
DXCore.Canvas.TexMap(FMetrics.RawTableBounds, clWhite4);
TableResources.TableImage
is of TAsphyreImage
type. DXCore.Canvas
is TAsphyreCanvas
.
This works fine and draws proper image. However, I have need to also draw black & white version of the same image (desaturate it).
I have tried to use various combinations of parameters in TexMap()
, but none gave nothing close to desaturated image. Some things I tried:
DXCore.Canvas.TexMap(FMetrics.RawTableBounds, cGray4(100));
DXCore.Canvas.TexMap(FMetrics.RawTableBounds, cRGB4(100, 100, 100));
There is 4th parameter to function that takes TBlendingEffect
enum, I tried various combinations with that too, but without success.
I also tried to manually desaturate image after loading it, with cLerp()
, like this:
procedure TTableResources.ImageToGrayscale(const AImage: TAsphyreImage);
var
C1: Integer;
x, y: Integer;
begin
for C1 := 0 to AImage.TextureCount - 1 do
for x := 0 to AImage.Texture[C1].Width - 1 do
for y := 0 to AImage.Texture[C1].Height - 1 do
AImage.Texture[C1].Pixels[x, y] := cLerp(AImage.Texture[C1].Pixels[x, y], cColor(cGrayValue(AImage.Texture[C1].Pixels[x, y])), 0.8);
end;
..but this works awfuly slow (~20-30 seconds to process one image), and doesnt return desired output.
Here are some documents from their help:
Does anyone know something more about this and can give me an hint or advice what I can try?
Asphyre Sphinx wasn't designed for processing images but for rendering them. It is a graphical engine suitable for making games.
Its original developer has ceased work on it. Currently it is maintained by a member of Pascal Game Development comunity named MarcoCestari. So if you have any questions related to Asphyre Sphinx you can join PGD comunity and ask there. These is a special forum section reserved for Asphyre Sphix library:
http://www.pascalgamedevelopment.com/forumdisplay.php?25-Asphyre-Component-Pack-(formerly-PowerDraw)
Now what you need would be some image processing library like Graphics32 for instance instead.