 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Chris Iverson Guest
|
Posted: Fri Jul 18, 2003 3:53 pm Post subject: Loading a Clipboard Image into a TJPEGIMAGE. |
|
|
I am trying to load a clipboard image into a TJPEGImage. I got it to work
with a Bitmap but no luck with jpeg. Here is my code. The comented out
stuff is for the Bitmap.
var
b : Graphics.TBitmap;
HWnd : THandle;
jp: TJPEGImage; //Requires the "jpeg" unit added to "uses" clause.
begin
SaveClpBrdImage := false;
if imageType = 0 then begin
// b := nil;
jp := nil;
if fileName <> '' then begin
try begin
if Clipboard.HasFormat(CF_BITMAP) then begin
try begin
// b := Graphics.TBitmap.Create;
jp := TJPEGImage.Create;
end;
except
on E: Exception do MessageDlg('CREATE JPEG ERROR - ' +
E.Message, mtError, [mbOk], 0);
end;
HWnd := Clipboard.GetAsHandle(CF_BITMAP);
try begin
// b.LoadFromClipboardFormat(CF_BITMAP, HWnd, 0);
I get an error here. I think I have to register the jpeg image but I don't
know how.
jp.LoadFromClipboardFormat(CF_BITMAP, HWnd, 0);
jp.Assign()
end;
except
on E: Exception do MessageDlg('LOAD CLIPBOARD ERROR - '
+ E.Message, mtError, [mbOk], 0);
end;
// b.PixelFormat := pf24bit;
jp.PixelFormat := jf24Bit;
try begin
// b.SaveToFile(fileName);
jp.SaveToFile(fileName);
end;
except
on E: Exception do MessageDlg('SAVE JPEG ERROR - ' +
E.Message, mtError, [mbOk], 0);
end;
// if b <> nil then begin
// b.Free;
jp.Free;
SaveClpBrdImage := true;
// end;
end;
end;
except
on E: Exception do MessageDlg('CLIPBOARD WRONG FORMAT ERROR - '
+ E.Message, mtError, [mbOk], 0);
end;
end;
end;
--
Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/
|
|
| Back to top |
|
 |
Earl F. Glynn Guest
|
|
| Back to top |
|
 |
Tiro Orsa Guest
|
Posted: Mon Jul 21, 2003 1:46 am Post subject: Re: Loading a Clipboard Image into a TJPEGIMAGE. |
|
|
Can't you just load it to the bitmap and then .Assign() it to the JPG and
then save it? using only the bitmap for memory transfer & canvas?
-Tiro Orsa
"Chris Iverson" <chris.iverson (AT) bentley (DOT) com> wrote
| Quote: | I am trying to load a clipboard image into a TJPEGImage. I got it to work
with a Bitmap but no luck with jpeg. Here is my code. The comented out
stuff is for the Bitmap.
var
b : Graphics.TBitmap;
HWnd : THandle;
jp: TJPEGImage; //Requires the "jpeg" unit added to "uses" clause.
begin
SaveClpBrdImage := false;
if imageType = 0 then begin
// b := nil;
jp := nil;
if fileName <> '' then begin
try begin
if Clipboard.HasFormat(CF_BITMAP) then begin
try begin
// b := Graphics.TBitmap.Create;
jp := TJPEGImage.Create;
end;
except
on E: Exception do MessageDlg('CREATE JPEG ERROR - ' +
E.Message, mtError, [mbOk], 0);
end;
HWnd := Clipboard.GetAsHandle(CF_BITMAP);
try begin
// b.LoadFromClipboardFormat(CF_BITMAP, HWnd, 0);
I get an error here. I think I have to register the jpeg image but I don't
know how.
jp.LoadFromClipboardFormat(CF_BITMAP, HWnd, 0);
jp.Assign()
end;
except
on E: Exception do MessageDlg('LOAD CLIPBOARD ERROR -
'
+ E.Message, mtError, [mbOk], 0);
end;
// b.PixelFormat := pf24bit;
jp.PixelFormat := jf24Bit;
try begin
// b.SaveToFile(fileName);
jp.SaveToFile(fileName);
end;
except
on E: Exception do MessageDlg('SAVE JPEG ERROR - ' +
E.Message, mtError, [mbOk], 0);
end;
// if b <> nil then begin
// b.Free;
jp.Free;
SaveClpBrdImage := true;
// end;
end;
end;
except
on E: Exception do MessageDlg('CLIPBOARD WRONG FORMAT ERROR -
'
+ E.Message, mtError, [mbOk], 0);
end;
end;
end;
--
Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/
|
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|