Converting Jpeg images to Bmp - some images come out blue

前端 未结 4 1036
忘了有多久
忘了有多久 2020-12-14 12:33

There are some Jpg images which Delphi doesn\'t seem to like. It appears to be specific with the files I\'m loading. And the procedure is simple - a) load Jpg image to

4条回答
  •  死守一世寂寞
    2020-12-14 12:36

    WIC (available for XP and up) can handle this image. This component is wrapped up nicely in Delphi 2010 and up. For earlier Delphi versions it is easy enough to call WIC using the COM interfaces.

    Here's my proof of concept code:

    var
      Image: TWICImage;
      Bitmap: TBitmap;
    begin
      Image := TWICImage.Create;
      Image.LoadFromFile('C:\desktop\ABrownImage.jpg');
      Bitmap := TBitmap.Create;
      Bitmap.Assign(Image);
      Bitmap.SaveToFile('C:\desktop\ABrownImage.bmp');
    end;
    

    Note 1: WIC is delivered with Vista but has to be re-distributed for XP. One obvious option would be to use WIC if available, but fall back to the Delphi JPEG decoder otherwise.

    Note 2: I can't find a re-distributable package for WIC. I suspect it may require end-user download for XP. That said I would not be at all surprised if the vast majority of XP machines had it installed by now.

提交回复
热议问题