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 

Is CF_DIB format supported by Picture.LoadFromClipboardForm

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





PostPosted: Sat May 19, 2007 1:50 pm    Post subject: Is CF_DIB format supported by Picture.LoadFromClipboardForm Reply with quote



Hi,

After verifying that there is a CF_DIB format on the clipboard, I call the
TPicture method LoadFromClipboardFormat(AFormat: Word; AData: THandle;
APalette: HPALETTE) with AFormat= CF_DIB. This gives 'Unsupported clipboard
format' error message.

CF_DIB had previously been registered by calling

TPicture.RegisterClipboardFormat(CF_DIB, TBitmap);

LoadFromClipboardFormat works for AFormat= CF_BITMAP;

Does this mean that TPicture cannot copy a DIB from the clipboard, or is
there likely to be some other cause of the error?

Regards,

Enquiring Mind
Back to top
Jens Gruschel
Guest





PostPosted: Sat May 19, 2007 5:02 pm    Post subject: Re: Is CF_DIB format supported by Picture.LoadFromClipboard Reply with quote



Quote:
After verifying that there is a CF_DIB format on the clipboard, I call the
TPicture method LoadFromClipboardFormat(AFormat: Word; AData: THandle;
APalette: HPALETTE) with AFormat= CF_DIB. This gives 'Unsupported clipboard
format' error message.

This exception message is used either if the format was not registered
or if the graphic class does not know how to handle it (at least TBitmap
raises such an exception in this case). TBitmap can only handle
CF_BITMAP. If a CF_DIB is available in the clipboard there's always a
CF_BITMAP available, too, and the other way round. So it's two different
ways to access the same clipboard data (more or less). It's quite
useless to support both, because whenever accessing the clipboard you
have to decide for one anyway. CF_BITMAP is more suitable if you are
working with handles (HBITMAP), CF_DIB is more suitable if you are
working with pixel data directly. The Delphi developers obviously
preferred handles.

Quote:
TPicture.RegisterClipboardFormat(CF_DIB, TBitmap);

Don't do that. By default following combinations are registered:

CF_METAFILEPICT, TMetafile
CF_ENHMETAFILE, TMetafile
CF_BITMAP, TBitmap

RegisterClipboardFormat is used when you want to add a new TGraphic
descendant supporting one or more clipboard formats. If you want to use
CF_DIB with TPicture you have to write your own TDIB class (or derive it
from TBitmap overriding LoadFromClipboardFormat and SaveToClipboardFormat).

--
Jens Gruschel
http://www.pegtop.net
Back to top
Enquiring Mind
Guest





PostPosted: Sat May 19, 2007 5:52 pm    Post subject: Re: Is CF_DIB format supported by Picture.LoadFromClipboard Reply with quote



"Jens Gruschel" <nospam (AT) nospam (DOT) nospam> wrote in message
news:464ee779 (AT) newsgroups (DOT) borland.com...

Quote:
This exception message is used either if the format was not registered or
if the graphic class does not know how to handle it (at least TBitmap
raises such an exception in this case). TBitmap can only handle CF_BITMAP.
If a CF_DIB is available in the clipboard there's always a CF_BITMAP
available, too, and the other way round. So it's two different ways to
access the same clipboard data (more or less). It's quite useless to
support both, because whenever accessing the clipboard you have to decide
for one anyway. CF_BITMAP is more suitable if you are working with handles
(HBITMAP), CF_DIB is more suitable if you are working with pixel data
directly. The Delphi developers obviously preferred handles.

First let me thanks very much for your support. I suppose the problem is

that I am not yet familiar with the differences in meaning between the
various standard Windows clipboard formats. If CF_BITMAP actually refers to
a bitmap handle, would I be right in thinking that when we copy to or from
the clipboard using CF_BITMAP, all we are copying is a handle to a Windows
bitmap object, and not the actual bitmap data itself? And conversely when we
copy a bitmap to or from the th clipboard using CF_DIB, we are copying the
actual data rather than a handle?

Having looked at the clipboard formats that are present on the clipboard
after an image has been copied from a MS Office application (which usually
include CF_BITMAP, CF_DIB, CF_ENHMETAFILE, CF_METAFILEPICT, GIF, PNG, JFIF,
etc.), I was wondering if copies of the source image converted into each of
these formats have been placed on the clipboard, (thereby swelling the
memory demand in the case of a high resolution photo, for example), or
whether the conversion only gets executed on demand when the data is
requested from the clipbaord.


Quote:

Don't do that. By default following combinations are registered:

CF_METAFILEPICT, TMetafile
CF_ENHMETAFILE, TMetafile
CF_BITMAP, TBitmap

RegisterClipboardFormat is used when you want to add a new TGraphic
descendant supporting one or more clipboard formats. If you want to use
CF_DIB with TPicture you have to write your own TDIB class (or derive it
from TBitmap overriding LoadFromClipboardFormat and
SaveToClipboardFormat).

Isn't DIB just another format for describing a standard Windows bitmap? Why

shouldn't the TBitmap class be able to read it? Or are we saying that the
TBitmap class hasn't been updated to keep up with Windows updates?

Enquiring Mind
Back to top
Jens Gruschel
Guest





PostPosted: Sat May 19, 2007 7:57 pm    Post subject: Re: Is CF_DIB format supported by Picture.LoadFromClipboard Reply with quote

Quote:
If CF_BITMAP actually refers to
a bitmap handle, would I be right in thinking that when we copy to or from
the clipboard using CF_BITMAP, all we are copying is a handle to a Windows
bitmap object, and not the actual bitmap data itself?

Right, the clipboard only contains the handle. That's all you need to
use the bitmaps (say draw it to some canvas). Usually the GetObject API
function is involved.

Quote:
And conversely when we
copy a bitmap to or from the th clipboard using CF_DIB, we are copying the
actual data rather than a handle?

Right, the clipboard contains a handle for the memory containing the data.

Quote:
Having looked at the clipboard formats that are present on the clipboard
after an image has been copied from a MS Office application (which usually
include CF_BITMAP, CF_DIB, CF_ENHMETAFILE, CF_METAFILEPICT, GIF, PNG, JFIF,
etc.), I was wondering if copies of the source image converted into each of
these formats have been placed on the clipboard, (thereby swelling the
memory demand in the case of a high resolution photo, for example), or
whether the conversion only gets executed on demand when the data is
requested from the clipbaord.

Windows does the conversion from CF_BITMAP to CF_DIB (and some other
formats), and I guess Windows does it on demand only, but it doesn't
really matter, you cannot influence it.

However Windows offers another feature called "delayed rendering": you
save a null value to the clipboard and wait for WM_RENDERFORMAT, which
is sent just at the time the data is required. That way you can provide
many formats without using much memory. MS Office probably places such
null values to the clipboard and waits what format the other application
pasting the data wants. Of course when your application is terminated
the data is lost if you don't render it to the clipboard before.

Quote:
Isn't DIB just another format for describing a standard Windows bitmap? Why
shouldn't the TBitmap class be able to read it? Or are we saying that the
TBitmap class hasn't been updated to keep up with Windows updates?

TBitmap both supports DIBs (device independent bitmaps) and DDBs (device
dependend bitmaps). The PixelFormat value is used for this. However
TBitmap does not support DIB clipboard operations. IMO TBitmap isn't
perfect for handling DIBs.

--
Jens Gruschel
http://www.pegtop.net
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.