Converting JPGs to BMPs

From: Christakis John (dontemail_at_me.please.ok)
Date: 11/10/04

  • Next message: Christakis John: "Re: Converting JPGs to BMPs"
    Date: Wed, 10 Nov 2004 06:52:52 GMT
    
    

    Hiya,

    I am trying to do this using streams instead of files. I started with this
    code:

    procedure Jpeg2Bmp(const BmpFileName, JpgFileName: string);
    var
      Bmp: TBitmap;
      Jpg: TJPEGImage;
    begin
      Bmp := TBitmap.Create;
      Jpg := TJPEGImage.Create;
      try
        Jpg.LoadFromFile(JpgFileName);
        Bmp.Assign(Jpg);
        Bmp.SaveToFile(BmpFileName);
      finally
        Jpg.Free;
        Bmp.Free;
      end;
    end;

    and changed it like this:

    try
        jpg.LoadFromStream(stmPhoto);
        Bmp.Assign(Jpg);
        Bmp.SaveToStream(stmBitmap);
    finally
        Jpg.Free;
        Bmp.Free;
    end;

    where stmPhoto is a TStream of a jpeg read from a database blob field and
    stmBitmap is a clean TStream object. I get 'Abstract errors'? Is there an
    easy way to do this? It feels like I am close, but I just can't get it
    working. I have looked at stmBitmap and it appears to contain the Jpeg
    info - there is a 'JFIF' eg.

    tia,
    cj


  • Next message: Christakis John: "Re: Converting JPGs to BMPs"

    Relevant Pages

    • Re: Cant Get Full Path From File Element
      ... whether a selected file is BMP or JPG. ... have other extensions, such as .jpeg or .raw (or whatever else a user ...
      (comp.lang.javascript)
    • Re: Show image img src=img.php?img=1.jpg help
      ... When i do that the image type is detected correctly as jpeg, ... But earlier you said this really is a bmp, not a jpg. ...
      (comp.lang.php)
    • Re: file extentions
      ... Can only Save Images in Internet Explorer as .BMP Files ... when there is no jpg or gif there? ... And yes they are saved as JPEG ...
      (microsoft.public.windowsxp.help_and_support)
    • Re: WinXp background wallpaper question
      ... > JPEG (JPG) is suggected. ... BMP is also good. ... Prev by Date: ...
      (microsoft.public.windowsxp.general)
    • RE: stego and executable files
      ... Hiding executables in the JPEG implies that whatever you use to read the ... to demostrate on JPG and BMP picture formates, ... Now to the structure of BMP files. ... Now JPG has structure more suitable for storage, ...
      (Security-Basics)