Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Clipboard reduces the resolution of the copied image

1,323 views
Skip to first unread message

curious

unread,
Sep 12, 2008, 5:59:04 PM9/12/08
to
Hi,

I apologize if this is the wrong forum to post this question. I am
not
sure which would be the best forum to post this question. Please
advise me if this is not the right forum.


Now my question. I have an Image being copied over to Clipboard using
Windows SetClipBoardData(UINT nFormat, HANDLE hMem) call.
The original Image has a resolution of 300 DPI. But, the Image being
copied over to the Clipboard has 86 DPI only. Incidentally, this
matches my monitor screen resolution as well.
I am saving the Image as a BITMAP ( by passing in CF_BITMAP as the
"nFormat" parameter value to the above SetClipBoardData() call. When
I
set the "nFormat" as CF_TIFF instead of CF_BITMAP, Clipboard gives an
error that the format is in binary and it cannot copy the file. The
exact error when CF_TIFF used is:
"The information is in a binary format. Clipbook viewer cannot
display
this format. To view the information, try pasting it into a
document."


Can anyone please let me know how I would be able to keep the image
resolution when copying over to the clipboard?
Or am I doing anything wrong?


Thanks in advance


Jonathan Wood

unread,
Sep 13, 2008, 12:30:59 PM9/13/08
to
I can't tell you what is happening but it is not the clipboard that is
changing anything. The clipboard only stores whatever data is placed there.

The first thing I'd do is try pasing into some different applications. You
gave very little description of how you determined the resolution was
reduced. What application did you paste it to??? Try pasting it to some
higher-end graphics application and see if the same thing happens. If you
can confirm that what is in the clipboard is really not the expected
resolution, then you need to look more closely at what you are storing
there.

The clipboard won't be modifying the resolution of an image stored there.

--
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com


"curious" <raja...@gmail.com> wrote in message
news:67898333-8b1d-4e75...@59g2000hsb.googlegroups.com...

curious

unread,
Sep 15, 2008, 11:17:47 AM9/15/08
to
On Sep 13, 12:30 pm, "Jonathan Wood" <jw...@softcircuits.com> wrote:
> I can't tell you what is happening but it is not the clipboard that is
> changing anything. The clipboard only stores whatever data is placed there.
>
> The first thing I'd do is try pasing into some different applications. You
> gave very little description of how you determined the resolution was
> reduced. What application did you paste it to??? Try pasting it to some
> higher-end graphics application and see if the same thing happens. If you
> can confirm that what is in the clipboard is really not the expected
> resolution, then you need to look more closely at what you are storing
> there.
>
> The clipboard won't be modifying the resolution of an image stored there.
>
> --
> Jonathan Wood
> SoftCircuits Programminghttp://www.softcircuits.com
>
> "curious" <rajayy...@gmail.com> wrote in message

>
> news:67898333-8b1d-4e75...@59g2000hsb.googlegroups.com...
>
>
>
> > Hi,
>
> > I apologize if this is the wrong forum to post this question. I am
> > not
> > sure which would be the best forum to post this question. Please
> > advise me if this is not the right forum.
>
> > Now my question. I have an Image being copied over to Clipboard using
> > Windows SetClipBoardData(UINT nFormat, HANDLE hMem) call.
> > The original Image has a resolution of 300 DPI. But, the Image being
> > copied over to the Clipboard has 86 DPI only. Incidentally, this
> > matches my monitor screen resolution as well.
> > I am saving the Image as a BITMAP ( by passing in CF_BITMAP as the
> > "nFormat" parameter value to the above SetClipBoardData() call. When
> > I
> > set the "nFormat" as CF_TIFF instead of CF_BITMAP, Clipboard gives an
> > error that the format is in binary and it cannot copy the file. The
> > exact error when CF_TIFF used is:
> > "The information is in a binary format. Clipbook viewer cannot
> > display
> > this format. To view the information, try pasting it into a
> > document."
>
> > Can anyone please let me know how I would be able to keep the image
> > resolution when copying over to the clipboard?
> > Or am I doing anything wrong?
>
> > Thanks in advance- Hide quoted text -
>
> - Show quoted text -

Hi Jonathan,

Thanks for the reply. I do all this programmatically using a 3rd party
software ofcourse to generate the BITMAP to be copied over to
clipboard. Of course when I save the same BITMAP to a file as a TIFF,
the resolution is not lost. But when I save it to the Clipboard, and
then when I paste it to viewers, I get a reduced resolution.
I tried a couple of viewers. The first one I tried is the Microsoft
Document Imaging - when I paste the bitmap into this application, I
see that the resolution is reduced. I then right click on it and check
the page properties which shows me the Resolution to be 86 DPI
( matching my monitor's resolution )

I then tried IrfanView as well. IrfanView application also shows us
the properties of the image but for those images that have been pasted
from the clipboard the resolution textboxes are blank. But, looking at
the image, I can clearly say that the resolution has been reduced.

Can you pleas suggest any other applications that I can test this
issue with?

Thanks in advance

David Ching

unread,
Sep 15, 2008, 12:58:14 PM9/15/08
to
"curious" <raja...@gmail.com> wrote in message
news:db628c18-6c1b-4d02...@x35g2000hsb.googlegroups.com...

> Can you pleas suggest any other applications that I can test this
> issue with?

How about Clipboard Viewer (Clipbrd.exe) that comes with Windows?

-- David


AliR (VC++ MVP)

unread,
Sep 15, 2008, 3:15:04 PM9/15/08
to
I would suspect that when the 3rd party is copying the bitmap they might be
using the screen dc in the CreateCompatibleBitmap method, instead of using a
dc that has your bitmap selected in it.

Anyway, copying a bitmap to the clipboard is a very simple task that you
don't need a 3rd party lib for.

http://www.codeguru.com/cpp/g-m/bitmap/article.php/c1715/

Any many more example on the net.

AliR.


"David Ching" <d...@remove-this.dcsoft.com> wrote in message
news:Iuwzk.355$be....@nlpi061.nbdc.sbc.com...

curious

unread,
Sep 15, 2008, 3:51:58 PM9/15/08
to
On Sep 15, 12:58 pm, "David Ching" <d...@remove-this.dcsoft.com>
wrote:
> "curious" <rajayy...@gmail.com> wrote in message

Hi David,

I have been toying with the Clipbrd.exe right from the beginning. I
can definitely see that the resolution has been already reduced.
Unfortunately Clipbrd.exe doesnt have a way to view the page
properties like other viewers do.

Thanks

curious

unread,
Sep 15, 2008, 3:53:50 PM9/15/08
to
On Sep 15, 3:15 pm, "AliR \(VC++ MVP\)" <A...@online.nospam> wrote:
> I would suspect that when the 3rd party is copying the bitmap they might be
> using the screen dc in the CreateCompatibleBitmap method, instead of using a
> dc that has your bitmap selected in it.
>
> Anyway, copying a bitmap to the clipboard is a very simple task that you
> don't need a 3rd party lib for.
>
> http://www.codeguru.com/cpp/g-m/bitmap/article.php/c1715/
>
> Any many more example on the net.
>
> AliR.
>
> "David Ching" <d...@remove-this.dcsoft.com> wrote in message
>
> news:Iuwzk.355$be....@nlpi061.nbdc.sbc.com...
>
>
>
> > "curious" <rajayy...@gmail.com> wrote in message

> >news:db628c18-6c1b-4d02...@x35g2000hsb.googlegroups.com...
> >> Can you pleas suggest any other applications that I can test this
> >> issue with?
>
> > How about Clipboard Viewer (Clipbrd.exe) that comes with Windows?
>
> > -- David- Hide quoted text -

>
> - Show quoted text -

Hi AliR,

That's a possiblity. But as I had explained in my post, when I use
this same Bitmap to create a TIFF file, I didnt see the reduction in
resolution. The new file was created with exactly the same resolution
as the old one.

THanks

Joseph M. Newcomer

unread,
Sep 17, 2008, 1:58:55 PM9/17/08
to
Note that there is no intrinsic dpi property of bitmap files. Therefore, any "report"
that it has some resolution is meaningless; it depends entirely upon what tool you are
using. Some file formats have metadata describing the resolution, but ultimately the ONLY
thing that matters is bits-wide * bits-high. The interpretation of those bits is done by
somebody else. If the program you are using claims that it is 86dpi, it has no basis for
that. (My camera, for example, takes 5 megapixels, but when I sent a full 5MPx (3MByte)
image to someone, they said they wanted a "high resolution" image and the one I sent them
was only 72 dpi. But it was a huge image)
joe

Joseph M. Newcomer [MVP]
email: newc...@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm

curious

unread,
Sep 17, 2008, 3:22:44 PM9/17/08
to
> email: newco...@flounder.com
> Web:http://www.flounder.com
> MVP Tips:http://www.flounder.com/mvp_tips.htm- Hide quoted text -

>
> - Show quoted text -

Hi Joe,

Thanks for the reply. I have a question though. Resolution is nothing
but the number of pixels( or dots ) per inch, right?
So, if I have a bitmap of say 540Pi X 360 Pi and if it fits in a 6"X4"
frame why can't I say that it's resolution is 90PPI? Pardon my
ignorance but shouldnt any image ( wheter it's a TIFF or BITMAP or
something else ) have resolution? It's just some metadata on the
image, isnt it?

THanks

Norbert Unterberg

unread,
Sep 17, 2008, 4:00:01 PM9/17/08
to

Joseph M. Newcomer schrieb:


> Note that there is no intrinsic dpi property of bitmap files.

Until now I was sure that the biXPelsPerMeter and biYPelsPerMeter fields of the
BITMAPINFOHEADER (which is part of the BMP file) contain the image's resolution.
If my calculation is correct a 72 dpi bitmap would have these fileds set to
someting like 2835. Am I wrong or missing something?

Norbert

Joseph M. Newcomer

unread,
Sep 18, 2008, 10:18:24 AM9/18/08
to
See below...

***
If you display it as 6x4, then you have a 90dpi image. But if your display is a printer,
the printer might have 1200dpi resolution; if you display the bitmap 1:1 on a printer, you
end up with a 0.45inch * 0.30inch image. Resolution in dpi is a function of the display
device rendering the pixels (assuming you have one pixel of your image displayed as one
pixel on the display device). So NO image has "resolution" because resolution does not
EXIST until the image is displayed! Images *only* have pixels. Display devices only have
pixels. If you display your image on a Jumbotron (one of those huge devices in sports
stadiums), with one pixel per jumbotron pixel, you end up with a resolution down in the
small-single-digits-per-inch, such as 3dpi or 2dpi. But it's the same image. So you
cannot claim that resolution is an intrinsic part of an image.

By the way, my display has a resolution of 120dpi, so if I displayed your image 1:1 it
would still be 540x360, but it would be 4.5"x3", ***but it would still be the same
image***.

The metadata might suggest resolution in dpi, but if the display system does not support a
resolution which is exactly that, the pixels will be expanded or compressed to cause the
image to render in the desired size. If this results in 1.27 image pixels per display
pixel, or 1.27 display pixels per image pixel, the image is actually going to be distorted
from what the file contains (in some cases, rather unpleasantly, if you use simple
StretchBlt to do the rendering).
joe
****
Joseph M. Newcomer [MVP]
email: newc...@flounder.com

Joseph M. Newcomer

unread,
Sep 18, 2008, 10:21:17 AM9/18/08
to
The metadata is intended to *suggest* the size that should be used to render the image.
This does not change the fact that the image is m*n pixels. The rendering engine may use
the bi[X|Y]PelsPerMeter to attempt to render the image in a specific size, but to do that,
it may have to distort the image (see my other answer: what if the rendering requires 1.27
image pixels per device pixel, or 1.27 device pixels per image pixel?) This is advisory
information and any application is free to ignore it. Note that in many real files, these
values are set to 0.
joe

On Wed, 17 Sep 2008 22:00:01 +0200, Norbert Unterberg <nunte...@newsgroups.nospam>
wrote:

0 new messages