How to get the complete graphic EXT supported? lazarus / 31-LCL ---------------------------------------------------------------------- jamie · 2024-06-08 18:53 I would like the complete list supported of all registered file formats for TPicture/TGraphic as a string I can breakup. I want to display to the user available types. I know I can request a type but that would mean I then need to specify it, so why bother? I simply need a complete delimited string of the extensions or descriptions without query each one. The needed functions are not exposed from the Graphics unit. I know I have done this before and can't remember how! it's a bitch getting old! ---------------------------------------------------------------------- dsiders · 2024-06-09 01:17 Quote from: jamie on June 08, 2024, 08:53:41 pmI would like the complete list supported of all registered file formats for TPicture/TGraphic as a string I can breakup. I want to display to the user available types. I know I can request a type but that would mean I then need to specify it, so why bother? I simply need a complete delimited string of the extensions or descriptions without query each one. Here's a couple of brute force routines: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i // text prior to '|' is the description// text after '|' is the file extension list (case-insensitive)// use AList.DelimitedText to get a Filter- compatible value for dialogsprocedure GetSupportedImages(AList: TStringList);begin  if (AList = Nil) then Exit;   if (AList.Count > 0) then AList.Clear;  Alist.Options := [];  AList.Delimiter := '|';  Alist.QuoteChar := ' ';   AList.Add('Cursor (*.cur)|*.cur');  AList.Add('Bitmap (*.bmp)|*.bmp');  {$IFDEF Windows}  AList.Add('Icon [Windows] (*.ico)|*.ico');  {$endif}  {$IFDEF Darwin}  AList.Add('Icon [macOS] (*.icns)|*.icns');  {$endif}  AList.Add('Portable Network Graphics (*.png)|*.png');  AList.Add('Pixmap (*.xpm)|*.xpm');  {$IFNDEF DisableLCLJPEG}  AList.Add('JPEG (*.jpg;*.jpeg)|*.jpg;*.jpeg');  {$ENDIF}  {$IFNDEF DisableLCLTIFF}  AList.Add('Tagged Image File Format (*.tif;*.tiff)|*.tif;*.tiff');  {$ENDIF}  {$IFNDEF DisableLCLGIF}  AList.Add('Graphics Interchange Format (*.gif)|*.gif');  {$ENDIF}  {$IFNDEF DisableLCLPNM}  AList.Add('Portable AnyMap Graphics (*.pnm)|*.pnm');  {$ENDIF}end; // Filter-compatible value for dialogsfunction GetSupportedImagesString: String;begin  Result := 'Cursor (*.cur)|*.cur|Bitmap (*.bmp)|*.bmp';  {$IFDEF Windows}  Result += '|Icon [Windows] (*.ico)|*.ico';  {$endif}  {$IFDEF Darwin}  Result += '|Icon [macOS] (*.icns)|*.icns';  {$endif}  Result += '|Portable Network Graphics (*.png)|*.png';  Result += '|Pixmap (*.xpm)|*.xpm';  {$IFNDEF DisableLCLJPEG}  Result += '|JPEG (*.jpg;*.jpeg)|*.jpg;*.jpeg';  {$ENDIF}  {$IFNDEF DisableLCLTIFF}  Result += '|Tagged Image File Format (*.tif;*.tiff)|*.tif;*.tiff';  {$ENDIF}  {$IFNDEF DisableLCLGIF}  Result += '|Graphics Interchange Format (*.gif)|*.gif';  {$ENDIF}  {$IFNDEF DisableLCLPNM}  Result += '|Portable AnyMap Graphics (*.pnm)|*.pnm';  {$ENDIF}end;  Quote from: jamie on June 08, 2024, 08:53:41 pmThe needed functions are not exposed from the Graphics unit. I know I have done this before and can't remember how! it's a bitch getting old!  Welcome to the club... now get off my lawn. ---------------------------------------------------------------------- jamie · 2024-06-09 13:06 That does not solve the problem at hand, it just displays the issue at hand.   There is a function to register a file format, therefor a list of these classes is maintained. However, there is no function to enumerate these classes.    It would be nice to Enumerate them so a list for the user can be populated because with the classes, you can obtain the needed data.   A perfect example would be if someone decided to add a image format to the list and all you would need to do is recompile the app and that format will not be present.  Currently, you need to query for a possible format and if that is the case then it's just a bunch of slop. ---------------------------------------------------------------------- dsiders · 2024-06-09 19:40 Quote from: jamie on June 09, 2024, 03:06:30 pmThat does not solve the problem at hand, it just displays the issue at hand.   There is a function to register a file format, therefor a list of these classes is maintained. However, there is no function to enumerate these classes.    It would be nice to Enumerate them so a list for the user can be populated because with the classes, you can obtain the needed data.   A perfect example would be if someone decided to add a image format to the list and all you would need to do is recompile the app and that format will not be present.  Currently, you need to query for a possible format and if that is the case then it's just a bunch of slop. I think we both missed the forest for the trees. graphics.pp already has GraphicFilter() and GraphicFileMask() just like the Delphi VCL equivalents. The thing that is not obvious is that they return a complete list for all supported graphic types when the graphic class argument is TGraphic. Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i ShowMessage('Filter = '  + GraphicFilter(TGraphic));ShowMessage('File Masks = ' + GraphicFileMask(TGraphic)); Curiously, there is no equivalent to get graphic class descriptions alone. It's also missing in Delphi. ---------------------------------------------------------------------- jamie · 2024-06-09 20:35 ok, Using the TGraphic by itself is good enough. There really should be a Enumerating Class list that is registered. Quote caption := GraphicFilter(TGraphic); Shows me the complete list which I can work with. I didn't see that documented that way for some reason? Thanks. ---------------------------------------------------------------------- dsiders · 2024-06-09 20:41 Quote from: jamie on June 09, 2024, 10:35:46 pmQuote caption := GraphicFilter(TGraphic); Shows me the complete list which I can work with. I didn't see that documented that way for some reason? No, you did not... and it's been added to my list. ---------------------------------------------------------------------- jamie · 2024-06-09 21:31 here is a simple test project to show the classes and their extensions.