How to draw disabled images with TsAlphaImageList

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #36344
    ralfiii
    Participant

    The normal TImageList component offers a method “TImageList.Draw” to paint images to a canvas.

    When the last parameter (Enabled) is false, then the image is painted in a disabled grayed look.

    Draw also works for TsAlphaImageList, but the last parameter is completely ignored.

    I also tried to use DrawAlphaImgListDC, but didn't manage to get grayscale picures.

    So how do get the disabled look?

    (see attached pic)

    Thanks!

    Ralf

    #52698
    Support
    Keymaster

    Hello Ralf!

    acAlphaImageList unit contains the DrawAlphaImgList function:

    Code:
    function DrawAlphaImgList(const ImgList: TCustomImageList; const DestBmp: TBitmap; const Left: integer; const Top: integer; const ImageIndex: integer; const Blend: integer; const GrayedColor: TColor; State: integer; const NumGlyphs: integer; const Reflected: boolean): TSize;

    This function allows to draw a glyph with many parameters, I hope it helps.

    Please, look it, and write again if you have questions.

    #52699
    ralfiii
    Participant

    Hello!

    I tried that function, but I didn't manage to get grayed glyphs.

    Here's the code that belongs to the screenshot from my previous post:

    Code:
    // The color of the pixel in the lower left corner defines the transparency color
    for counter:=0 to ImageList1.Count-1 do
    ImageList1.Draw(Canvas, 10,10+40*counter, counter);
    for counter:=0 to ImageList1.Count-1 do
    ImageList1.Draw(Canvas, 30,10+40*counter, counter, False);

    for counter:=0 to sAlphaImageList1.Count-1 do
    sAlphaImageList1.Draw(Canvas, 50,10+40*counter, counter);
    for counter:=0 to sAlphaImageList1.Count-1 do
    sAlphaImageList1.Draw(Canvas, 70,10+40*counter, counter, False);
    for counter:=0 to sAlphaImageList1.Count-1 do
    DrawAlphaImgListDC(sAlphaImageList1, Canvas.Handle, 90, 10+40*counter, counter,
    0 {Blend}, $BEA76D {GrayedCol}, 0 {State}, 1 {NumGlyphs}, False {reflect});
    for counter:=0 to sAlphaImageList1.Count-1 do
    DrawAlphaImgListDC(sAlphaImageList1, Canvas.Handle, 110, 10+40*counter, counter,
    50 {Blend}, clNone {GrayedCol}, 0 {State}, 1 {NumGlyphs}, False {reflect});

    I didn't manage to make the GreyedCol parameter do something meaningful.

    Could you change the code so the back arrow is properly grayed?

    Or is the only way to draw the images transparent?

    Thanks,

    Ralf

    #52700
    Support
    Keymaster

    If glyphs must be gray toned, then leave 0 there.

    GrayedCol is a tone for glyph (if clRed, then glyph will have red tones).

    #52705
    ralfiii
    Participant

    Hey!

    Ok, if I call

    Code:
    DrawAlphaImgListDC(sAlphaImageList1, Canvas.Handle, 10, 10, 0,
    0 {Blend}, 0 {GrayedCol}, 0 {State}, 1 {NumGlyphs}, False {reflect});

    then the bitmap really becomes monochrome, but an icon that was completely black is still black. So it doesn't look disabled.

    To get such an icon the proper look I have to call with Blend=70

    But if I do that, an icon that was only in colors suddenly is extremely pale.

    see attached pic.

    In my case that's no problem, I know the graphics and only need it for one special case, but the way DrawAlphaImgListDC works now is not good for a general solution.

    Best regards,

    Ralf

    #52716
    Support
    Keymaster

    I understand what you mean, but I have no idea how to improve it at the moment. I have added this issue in ToDo list and I will think later about that.

    #52717
    ralfiii
    Participant
    'Support' wrote:

    I understand what you mean, but I have no idea how to improve it at the moment. I have added this issue in ToDo list and I will think later about that.

    Ok, no problem.

    Thanks.

Viewing 7 posts - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.