Article View: borland.public.cppbuilder.nativeapi
Article #16921Re: Screen unit convert
From: user
Date: Mon, 21 Apr 2003 04:07
Date: Mon, 21 Apr 2003 04:07
27 lines
2002 bytes
2002 bytes
Sky wrote:
> hi all, I want draw a bitmap on the form,
> Graphics::TBitmap *bmp = new Graphics::TBitmap();
> bmp->LoadFromFile("C:\\temp.bmp");
> bmp->Width = 320; bmp->Height = 240;
> Canvas->Draw(0,0,bmp);
> delete bmp;
>
> My Question is: Can i convert the size to metric.
> I want set the width of bmp 10cm,
> does anyone can tell me how to do it?
> at the same time i want print it with 10cm on paper.
> TIA
>
> Sky
>
>
A bitmap is only measured in pixels, so in order to convert it to some
specific size, you'll need to calculate the number of pixels that
correspond to that measurement on the output device and then crop or
scale the bitmap appropriately. You should be able to get the
information you need to convert pixels to centimeters using the API
function GetDeviceCaps() for the screen and DeviceCapabilities() for the
printer. Don't expect a high degree of accuracy on the screen, though; I
think I read that the numbers returned by monitor device drivers are
very, very unreliable.
Technical Details
Message-ID:
<3EA36E9C.307@domain.invalid>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!sn-xit-01!sn-xit-08!supernews.com!newsfeed.wirehub.nl!news.kweb.on.ca!KWeb!newsgroups.borland.com!not-for-mailReferences:
<3ea349fc$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10cc67,2dd5cea066b7e2a3 X-Google-Attributes: gid10cc67,public X-Google-ArrivalTime: 2003-04-20 21:11:10 PST Message-ID: <3EA36E9C.307@domain.invalid> Date: Mon, 21 Apr 2003 00:07:56 -0400 From: user@domain.invalid User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.0.2) Gecko/20030208 Netscape/7.02 X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: borland.public.cppbuilder.nativeapi Subject: Re: Screen unit convert References: <3ea349fc$1@newsgroups.borland.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 151.201.18.183 X-Trace: newsgroups.borland.com 1050898095 151.201.18.183 (20 Apr 2003 21:08:15 -0700) Lines: 28 Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!sn-xit-01!sn-xit-08!supernews.com!newsfeed.wirehub.nl!news.kweb.on.ca!KWeb!newsgroups.borland.com!not-for-mail