How TO save the Clipboard's BMP data as Gif or Jpg file?

How TO save the Clipboard's BMP  data as  Gif  or Jpg file?
first ,I copy a image to Clipboard,and then I want to save these data to a Gif or Jpg file.
I need some source codes or good idea. TKS.
ymq8328Asked:
Who is Participating?
 
mahesh1402Commented:
Have a look at GetClipboardData() function....

You need code something like following to retrieve bitmap from clipboard to DC :

         //Get the clipboard data
      HBITMAP handle = (HBITMAP)GetClipboardData(CF_BITMAP);
      CBitmap * bm = CBitmap::FromHandle(handle);

      CClientDC cdc(this);
      CDC dc;
      dc.CreateCompatibleDC(&cdc);
      dc.SelectObject(bm);
      cdc.BitBlt(0,0,200,200,&dc,0,0,SRCCOPY);

      CloseClipboard();

Have a look at this sample project with src :
All you ever wanted to know about the Clipboard...
http://www.codeproject.com/clipboard/clipboard_faq.asp <== c

Now about converting your BMP to JPG you have many options like GDI+ library or other third party libraries like CxImage etc

Have a look at this :
http://www.codeguru.com/cpp/g-m/bitmap/capturing/article.php/c4915/ <==

Hope This Helps.

-MAHESH
0
 
ymq8328Author Commented:
I think this is a easy but not good method.
1,save the Clipboard's data to BMP file.
2,convert the BMP file to gif of jpg file.
0
 
mahesh1402Commented:
I think using libJPEG standard JPG libraries will be easy way for you...

You may refer this about this libraries with src.. Following ImageHandler is A Component to Copy an HDC Area to a JPEG File :

http://www.codeguru.com/cpp/g-m/bitmap/otherformats/article.php/c4941/ <== Refer Full Article

-MAHESH
0
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

 
DanRollinsCommented:
VS7 makes use of the features of GDI+ to save in various formats, including JPEG:
     CImage::Save  
     http://msdn2.microsoft.com/en-us/d06f3fhw.aspx
0
 
mahesh1402Commented:
Why Grade 'C' ????
0
 
ymq8328Author Commented:
dear mahesh1402.
your answer can't help me  directly,I need to do a lot of other work.
thanks again.
0
 
mahesh1402Commented:
if you want further assistance or u have not satisfied with above you may ask your quesries by posting them here......we may further comment on it to solve it.

Can I ask you what problems you had with above solution ?

-MAHESH
0
 
ymq8328Author Commented:
U are a hot heart guy.
I have solved this problem by using other JPG lib.
I am a electronic engineer,I kown few MFC.so,I  judge your answer like this.
A , I can use it directly.
B, few modify.
C,a lot of modify.
Thanks.
0
 
mahesh1402Commented:
No not HOT heart..I really asked if you have really any problems with above solutions.... :)

Here we can redirect you towards right directions instead of providing  100% ready solutions or code.. So here 'C' considered as bad assist which is even not near to your problem solutions !

-MAHESH
0
 
ymq8328Author Commented:
'C' considered as bad assist ?
No,you assistance is usefull for me.I don't kown that. sorry for this.I think I can't do this mistake.How can I remedy this?
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.