Draw Bitmap on the screen (no deformation)

Login to reply to this topic.
Wed, 2007-07-18 13:40
Joined: 2006-02-23
Forum posts: 17

I have a CFbsBitmap called aImage.

I want to draw it on the screen.

I use this code:

CWindowGc& gc = SystemGc();
// Update the screen
gc.Activate(Window());
TRect drawRect(Rect());
gc.Clear(drawRect);

gc.DrawBitmap(drawRect, aImage);

This function, DrawBitmap, scales the bitmap in order to fit inside the TRect called drawRect. Is it possible to make it fit but without changing the aspect ratio? I mean, if the Rect is 320x240 and the original image is 3200x480, I would like to have a result of 320x48 on the screen (the same ratio) and not a 320x240 deformed one.

Any Idea is welcome.


Wed, 2007-07-18 18:17
NewLC AdministratorSymbian AccreditedForum Nokia Champion
Joined: 2003-01-14
Forum posts: 1919
Re: Draw Bitmap on the screen (no deformation)

Use BitBlt instead of DrawBitmap.


Eric Bustarret
NewLC Founder & CEO / Professional Symbian OS Consultant

Thu, 2007-07-19 04:07
Joined: 2004-05-21
Forum posts: 285
Re: Draw Bitmap on the screen (no deformation)

Use DrawBitmap(drawRect, aImage, drawRect) or use BitBlit as Eric said.

Cheers,
Sri

Thu, 2007-07-19 09:55
Joined: 2006-02-23
Forum posts: 17
Re: Draw Bitmap on the screen (no deformation)

As far as I know, BitBlt doesn´t scale the image, and I want to to scale it, but without deformation and without defining the size of the TRect again.

I mean, my TRect is almost screen size, and I want my large images to fit in the screen without deformation. Neither BitBlt or DrawBitmap in the way that I was using before could helpme, so... how can I use this DrawBitmap, like....

DrawBitmap(drawRect, aImage, drawRect)

??
How will this make the image fit the TRect without deformation??

BR

Miguel

Thu, 2007-07-19 11:23
Joined: 2004-05-21
Forum posts: 285
Re: Draw Bitmap on the screen (no deformation)

AFAIK you should either use SVG images or implement your own algorithm (which is very time consuming and difficult).

Cheers,
Sri

Mon, 2007-07-30 09:17
Joined: 2004-11-29
Forum posts: 1156
Re: Draw Bitmap on the screen (no deformation)

Huh? You don't have to invent new algoritms or use special image formats to maintain your aspect ratio when scaling...

Just make sure your new destination Draw Rect has the same aspect ratio, and adjust it if it doesn't.

compare width/height...

a/b = A/B

then solve the equation....

Mon, 2007-07-30 14:01
Joined: 2006-02-23
Forum posts: 17
Re: Draw Bitmap on the screen (no deformation)

Thanks.
I guess there is no other way than trying to compute the values of the TRect in order to have exactly the same aspect ratio.

  • Login to reply to this topic.