๐Ÿš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.cppbuilder.nativeapi
4 messages
4 total messages Started by Sky Mon, 21 Apr 2003 01:31
Screen unit convert
#16920
Author: Sky
Date: Mon, 21 Apr 2003 01:31
14 lines
1392 bytes
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
Re: Screen unit convert
#16921
Author: user
Date: Mon, 21 Apr 2003 04:07
27 lines
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.
Re: Screen unit convert
#16924
Author: Asger J๏ฟฝrgensen
Date: Mon, 21 Apr 2003 06:56
36 lines
2046 bytes
Hi Sky

  In article <3ea349fc$1@newsgroups.borland.com>,  Sky says :

> 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;

You should not set the height and width on a bimap
that contains an image, instead You should use something
like this


TRect Dest = Rect(0, 0, 320, 240);
TRect Src = Rect(0, 0, bmp->Width, bmp->Height);
SetStretchBltMode(Form1->Canvas->Handle, HALFTONE);
SetBrushOrgEx(Form1->Canvas->Handle, 0, 0, 0);
Form1->Canvas->CopyRect(Dest, bmp->Canvas, Src);

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

The only way You can do this is to make the user deside
what is equal to 10 cm, Let them size a for to 10 * 10 cm
and then save that to Your settings.
PixelsPerInch can vary from 96 -> 192 but it is in no
way accurate since the users can choose what ever they 
want on their screen.

Best regards
Asger
Re: Screen unit convert
#16841
Author: Sky
Date: Tue, 22 Apr 2003 02:19
1 lines
958 bytes
Thanks a lot.
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads