graphics images (BMP or JPEG) to BMP

graphics images (BMP or JPEG) to BMP

Post by Paul Nicholl » Fri, 09 Jul 1999 04:00:00


I have written a auto desktop background updating program using Delphi
3(Standard) which takes  the graphic image pointed to by filenames in a
TListBox, places it in a 'BGWizard.bmp' file in the windows directory and
makes the desktop bitmap become this graphic.  The problem is, even after I
registered JPEG files with TImage (after creating a JPEG package including
the .pas files from the CD)  I get a EInvalidGraphic with message 'Unknown
picture file extension (.jpg)' error message at GetWindowsDirectory(wd, 63);
in the code below.

If the file is a BMP graphic, I seem to get a Access Violation error
eventhough the desktop is altered correctly.

I know the registration worked ok because if I place a TImage on a form and
load a picture, one of the picture type option is for jpeg files.   does
anyone have any hints as to what I am doing wrong or what? Help!

Var
    Image    : TImage;
.
.
.
procedure TBGWizard.UpdatePicture;
Var
    wd  : array [0..63] of Char;
     s  : String;
     BitmapName : String;
Begin
    BitmapName := BitmapList.Items[BitmapListIndex];
     Image.Picture.LoadFromFile(BitmapName);
     GetWindowsDirectory(wd, 63);
     s := (wd + '\' + 'BGWizard.bmp');
     Image.Picture.SaveToFile(s);

SystemParametersInfo(SPI_SETDESKWALLPAPER,SPI_SETDESKWALLPAPER,PChar(S),SPIF
_UPDATEINIFILE);
End;

--
Paul Nicholls.
********************************************************
Live long and optimise
--------------------------------
Web Page : www.southcom.com.au/~phantom

 
 
 

graphics images (BMP or JPEG) to BMP

Post by Jon E. Scot » Fri, 09 Jul 1999 04:00:00


Paul,

I'm not sure but I think you're not allocating enough memory for the
GetWindowsDirectory function.  This is what I do to get the Windows directory:

var
  WindowsDir: string;
  pWindowsDir: array[0..144] of char;
begin
  GetWindowsDirectory(pWindowsDir, SizeOf(pWindowsDir));
  WindowsDir := Uppercase(StrPas(pWindowsDir) + '\');
  ...
  ...
end;

The TImage component should load JPGs without problems once you've added the
JPEG unit to your project.

Jon.


> I have written a auto desktop background updating program using Delphi
> 3(Standard) which takes  the graphic image pointed to by filenames in a
> TListBox, places it in a 'BGWizard.bmp' file in the windows directory and
> makes the desktop bitmap become this graphic.  The problem is, even after I
> registered JPEG files with TImage (after creating a JPEG package including
> the .pas files from the CD)  I get a EInvalidGraphic with message 'Unknown
> picture file extension (.jpg)' error message at GetWindowsDirectory(wd, 63);
> in the code below.

> If the file is a BMP graphic, I seem to get a Access Violation error
> eventhough the desktop is altered correctly.

> I know the registration worked ok because if I place a TImage on a form and
> load a picture, one of the picture type option is for jpeg files.   does
> anyone have any hints as to what I am doing wrong or what? Help!

> Var
>     Image    : TImage;
> .
> .
> .
> procedure TBGWizard.UpdatePicture;
> Var
>     wd  : array [0..63] of Char;
>      s  : String;
>      BitmapName : String;
> Begin
>     BitmapName := BitmapList.Items[BitmapListIndex];
>      Image.Picture.LoadFromFile(BitmapName);
>      GetWindowsDirectory(wd, 63);
>      s := (wd + '\' + 'BGWizard.bmp');
>      Image.Picture.SaveToFile(s);

> SystemParametersInfo(SPI_SETDESKWALLPAPER,SPI_SETDESKWALLPAPER,PChar(S),SPIF
> _UPDATEINIFILE);
> End;

> --
> Paul Nicholls.
> ********************************************************
> Live long and optimise
> --------------------------------
> Web Page : www.southcom.com.au/~phantom


 
 
 

graphics images (BMP or JPEG) to BMP

Post by Paul Nicholl » Sat, 10 Jul 1999 04:00:00


I tried your solution and am getting a black screen for the background.  I
will check this problem out...thanks.

--
Paul Nicholls.
********************************************************
Live long and optimise
--------------------------------
Web Page : www.southcom.com.au/~phantom

 
 
 

graphics images (BMP or JPEG) to BMP

Post by philng » Sat, 10 Jul 1999 04:00:00


did you have JPEG in your uses clause?


>I have written a auto desktop background updating program using Delphi
>3(Standard) which takes  the graphic image pointed to by filenames in a
>TListBox, places it in a 'BGWizard.bmp' file in the windows directory and
>makes the desktop bitmap become this graphic.  The problem is, even after I
>registered JPEG files with TImage (after creating a JPEG package including
>the .pas files from the CD)  I get a EInvalidGraphic with message 'Unknown
>picture file extension (.jpg)' error message at GetWindowsDirectory(wd,
63);
>in the code below.

>If the file is a BMP graphic, I seem to get a Access Violation error
>eventhough the desktop is altered correctly.

>I know the registration worked ok because if I place a TImage on a form and
>load a picture, one of the picture type option is for jpeg files.   does
>anyone have any hints as to what I am doing wrong or what? Help!

>Var
>    Image    : TImage;
>.
>.
>.
>procedure TBGWizard.UpdatePicture;
>Var
>    wd  : array [0..63] of Char;
>     s  : String;
>     BitmapName : String;
>Begin
>    BitmapName := BitmapList.Items[BitmapListIndex];
>     Image.Picture.LoadFromFile(BitmapName);
>     GetWindowsDirectory(wd, 63);
>     s := (wd + '\' + 'BGWizard.bmp');
>     Image.Picture.SaveToFile(s);

>SystemParametersInfo(SPI_SETDESKWALLPAPER,SPI_SETDESKWALLPAPER,PChar(S),SPI
F
>_UPDATEINIFILE);
>End;

>--
>Paul Nicholls.
>********************************************************
>Live long and optimise
>--------------------------------
>Web Page : www.southcom.com.au/~phantom

 
 
 

graphics images (BMP or JPEG) to BMP

Post by Paul Nicholl » Sat, 10 Jul 1999 04:00:00


I had included it after reading the post by Jon E. Scott and was having the
new problem I mentioned above.

--
Paul Nicholls.
********************************************************
Live long and optimise
--------------------------------
Web Page : www.southcom.com.au/~phantom