Board index » delphi » Converting a Jpeg file to a Bitmap file

Converting a Jpeg file to a Bitmap file

I have a bunch of Jpeg format images, and I want to save them to Bitmap
format files with the same name (except for the extension)

How can I do this? I've tried loading them in a TImage and saving them but
it doesn't want to know about it.

--

Luke Pascoe
Programming
Ihug

"I'm out of my mind, but feel free to leave a message."

 

Re:Converting a Jpeg file to a Bitmap file


You have to include the JPEG unit to your uses clause.
Quote
Pestilence wrote in message <7o80k0$ki...@newsource.ihug.co.nz>...
>I have a bunch of Jpeg format images, and I want to save them to Bitmap
>format files with the same name (except for the extension)

>How can I do this? I've tried loading them in a TImage and saving them but
>it doesn't want to know about it.

>--

>Luke Pascoe
>Programming
>Ihug

>"I'm out of my mind, but feel free to leave a message."

Re:Converting a Jpeg file to a Bitmap file


Didn't mean to sound too simplistic without a sample so...
Add the JPEG unit to the USES clause.  Then have a function...

procedure ConvertJPGtoBMP(F_Name : string);
var J : TJpegImage;
    B : TBitMap;
begin
    J := TJpegImage.Create;
    try
        B := TBitMap.Create;
        try
            J.LoadFromFile(F_Name);
            B.Assign(J);
            B.SaveToFile(ChangeFileExt(F_Name,'.bmp'));
        finally
            B.Free;
        end;
    finally
        J.Free;
    end;
end;

Quote
BlueGI wrote in message ...
>You have to include the JPEG unit to your uses clause.

>Pestilence wrote in message <7o80k0$ki...@newsource.ihug.co.nz>...
>>I have a bunch of Jpeg format images, and I want to save them to Bitmap
>>format files with the same name (except for the extension)

>>How can I do this? I've tried loading them in a TImage and saving them but
>>it doesn't want to know about it.

>>--

>>Luke Pascoe
>>Programming
>>Ihug

>>"I'm out of my mind, but feel free to leave a message."

Re:Converting a Jpeg file to a Bitmap file


Thankyou thankyou thankyou, I worked a charm.

I altered it slighty so it takes an in_FileName and out_FileName but
otherwise its perfect =)

--

Luke Pascoe
Programming
Ihug

"I'm out of my mind, but feel free to leave a message."

Quote
BlueGI <giwachowNOS...@bcw-usaNOSPAM.com> wrote in message

news:FCWp3.16$aY1.741@client...
Quote
> Didn't mean to sound too simplistic without a sample so...
> Add the JPEG unit to the USES clause.  Then have a function...

> procedure ConvertJPGtoBMP(F_Name : string);
> var J : TJpegImage;
>     B : TBitMap;
> begin
>     J := TJpegImage.Create;
>     try
>         B := TBitMap.Create;
>         try
>             J.LoadFromFile(F_Name);
>             B.Assign(J);
>             B.SaveToFile(ChangeFileExt(F_Name,'.bmp'));
>         finally
>             B.Free;
>         end;
>     finally
>         J.Free;
>     end;
> end;
> BlueGI wrote in message ...
> >You have to include the JPEG unit to your uses clause.

> >Pestilence wrote in message <7o80k0$ki...@newsource.ihug.co.nz>...
> >>I have a bunch of Jpeg format images, and I want to save them to Bitmap
> >>format files with the same name (except for the extension)

> >>How can I do this? I've tried loading them in a TImage and saving them
but
> >>it doesn't want to know about it.

> >>--

> >>Luke Pascoe
> >>Programming
> >>Ihug

> >>"I'm out of my mind, but feel free to leave a message."

Other Threads