BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Loading a Clipboard Image into a TJPEGIMAGE.

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Graphics
View previous topic :: View next topic  
Author Message
Chris Iverson
Guest





PostPosted: Fri Jul 18, 2003 3:53 pm    Post subject: Loading a Clipboard Image into a TJPEGIMAGE. Reply with 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
Earl F. Glynn
Guest





PostPosted: Sat Jul 19, 2003 12:03 am    Post subject: Re: Loading a Clipboard Image into a TJPEGIMAGE. Reply with quote



"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.

According to Peter Below this can not be done:
http://www.efg2.com/Lab/Library/UseNet/2001/1124.txt


--
efg -- Earl F. Glynn, Overland Park, KS USA

efg's Computer Lab: http://www.efg2.com/Lab
Mirror: http://homepages.borland.com/efg2lab/Default.htm



Back to top
Tiro Orsa
Guest





PostPosted: Mon Jul 21, 2003 1:46 am    Post subject: Re: Loading a Clipboard Image into a TJPEGIMAGE. Reply with quote



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
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Graphics All times are GMT
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.