Hello everyone,
my first post here, I got directed to this forum from following StackOverflow thread.
I am using AsphyreSphinx framework to draw 2D DirectX scene on form canvas. I am drawing image to form canvas like this:
Code:
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:
Code:
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:
Code:
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.
SilverWarrior answered me that this isnt really possible with Asphyre, and I would have to utilize other libraries for that. So my question is, how can I fast desaturate image that is 1200x800px? Is this really not possible with Asphyre (e.g. some combination of color + blending effect in TexMap()?)? Thanks!
Bookmarks