Icon quality in Ribbon

Add-in Express™ Support Service
That's what is more important than anything else

Icon quality in Ribbon
 
Andrei Smolin


Add-in Express team


Posts: 14137
Joined: 2006-05-11
Hi Vladimír,

The issue consists of two parts. First, ImageList corrupts the image. Then, as you've noticed, Office makes some small changes, too. Here's how you bypass the ImageList-related part of the issue.

procedure TAddInModule.adxRibbonTab1Controls0Controls0PropertyChanging(
  Sender: TObject; PropertyType: TadxRibbonControlPropertyType;
  var Value: OleVariant; const Context: IDispatch);
var
  icon : TIcon;
  Pict: IPictureDisp;
  PictureDesc: TPictDesc;
begin
  if PropertyType = rcptGlyph then begin
    icon := TIcon.Create;
    icon.LoadFromFile('d:Test.ico');

    PictureDesc.cbSizeofstruct := SizeOf(PictureDesc);
    PictureDesc.picType := PICTYPE_ICON;
    PictureDesc.hbitmap := 0;
    icon.Handle;
    PictureDesc.hIcon := icon.ReleaseHandle;
    PictureDesc.hpal := icon.Palette;
    OleCreatePictureIndirect(PictureDesc, ActiveX.IPicture, False, Pict);
    Value:= Pict;
    icon.Free;
  end;
end;


Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 04 Apr, 2014 06:06:43 Top
Vladimír Klaus




Posts: 20
Joined: 2014-03-03
Hello Andrei,

thank you very much for this code. It works perfectly!!!

I've just found how to improve default behavior. It's worse then described but doesn't need external files.

  if PropertyType = rcptGlyph then begin
    MyIconIndex:=TadxRibbonButton(Sender).ImageIndex;
    icon := TIcon.Create;
    ImageList1.GetIcon(MyIconIndex, icon);


One more improvement since DevEx cxImageList is better then default one.
cxImageList1.GetIcon(MyIconIndex, icon);

Here is the small comparison:
http://temp.audrey.cz/addinexpress/IconQuality5.png

1-your default, 2-ImageList, 3-cxImageList, 4-LoadFromFile, 5-Photoshop


Vladimír
Posted 11 Apr, 2014 07:48:50 Top
Andrei Smolin


Add-in Express team


Posts: 14137
Joined: 2006-05-11
Great! Thank you!

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 11 Apr, 2014 07:59:35 Top