IT SOLUTIONS
Your full service technology partner! 
-Collapse +Expand
Delphi
Search Delphi Group:

Advanced
-Collapse +Expand Delphi To/From
To/FromCODEGuides
-Collapse +Expand Delphi Store
PRESTWOODSTORE

Prestwood eMagazine

April Edition
Subscribe now! It's Free!
Enter your email:

   ► MB LobbyPascal and Delphi Coding BoardDelphi Single User Apps Topic   Print This     

copying a bmp into a timage

copying a bmp into a timage in Delphi Single User Apps topic (part of our Pascal and Delphi Coding group).

Quick Search: copying   copying bmp   copying bmp into  
Cerverza
bcn
hi friends!
I want to copy a bmp into a timage whitout the copyrect method of the timage or the strechtdraw because the bmp loses a lot of quality with these methods
what can i do to get the better quality??? [Help]
thanks.
 Posted 18 years ago (Thread Starter)
Comment Quote
About Cerverza -Collapse +Expand
Visit Profile
Membership pending.
Member subscribes to this thread but email is NOT VERIFIED.
Email Not Verified!
Once email is verified, we will review and approve the account.
Web Presence Hidden.
Once above is taken care of, full Profile content will display including back links, about me, my message, custom Profile html, social networking links, message board signature, company profile, etc.

Post ID #8327, 3 replies
Thread Started 11/18/2002 2:53:00 AM
View Counter=1334
Last Reply Posted 11/20/2002 6:39:00 AM)
Location=bcn  
Joined=18 years ago   MB Posts=2  
Scott Wehrly
Prestwood IT
 (Inactive)
Las Vegas, NV USA
I'm not sure what you mean by "loss of quality". I'll assume that you mean that the palette colors are reduced or replaced, which I find happens sometimes when editing BMP files.

There is an excellent component from InfoPower's First Class suite, called a TfcImager, that works well with bitmap images of 256 or higher colors. It has properties and methods that allow the palette to be preserved, and even allow for changing the image's brightness, contrast, hue, etc. in Delphi.
 Posted 18 years ago
Comment Quote
About Scott Wehrly -Collapse +Expand
Visit Profile
Inactive member.
Member does not subscribe to this thread.
Old Account!
If this is your account, sign in to activate web presence data (sign in quarterly to keep active). Alternatively, you can subscribe to our monthly eMag with a valid email address.
Web Presence Hidden.
Once above is taken care of, full Profile content will display including back links, about me, my message, custom Profile html, social networking links, message board signature, company profile, etc.

Post ID #8346 (Level 1.1)  Reply to 8327
Thread Started 11/19/2002 7:28:00 AM
View Counter=2
Location=Las Vegas, NV USA 
Joined=18 years ago   MB Posts=442   KB Posts=19  
Most Recent Post
Scott Wehrly
Prestwood IT
 (Inactive)
Las Vegas, NV USA
Okay, then rather than use CopyRect, why not try loading the image into a TBitmap to get its dimensions, and adjusting the TImage properties before you assign the picture.



If your TImage is anchored on an alignment (i.e. alTop, alClient, etc.) then you need to set AutoSize to False, and Center to True.



If the alignment is alNone, set AutoSize to True, and you'll need to adjust the TImage position based on its dimensions.



Your loss in quality is due to the fact that the TImage is stretching the image based on your alignment settings.



To find out the dimensions of the bitmap image before it is assigned to the TImage component, and reposition the TImage accordingly, try this:

procedure LoadMyImage(bmpFileName : string;reposition:boolean);
var
  Bitmap: TBitmap;
  bHeight, bWidth : integer;
begin
  try
    Bitmap := TBitmap.Create;
    Bitmap.LoadFromFile(bmpFileName);
    bHeight := Bitmap.Height;
    bWidth := Bitmap.Width;
    Clipboard.Assign(Bitmap);
    if reposition then
    begin
      FormImage.Alignment := alNone;
      FormImage.AutoSize := True;
      FormImage.Center := False;
      // Center on the form's canvas
      FormImage.Top := Trunc((Form1.ClientHeight / 2) - (bHeight / 2));
      FormImage.Left := Trunc((Form1.ClientWidth / 2) - (bWidth / 2));
    end
    else
    begin
      FormImage.Alignment := alClient;
      FormImage.AutoSize := False;
      FormImage.Center := True;
    end;
    FormImage.Picture.Assign(Clipboard);
  finally
    Bitmap.Free;
  end;
end;
 Posted 18 years ago
Comment Quote
About Scott Wehrly -Collapse +Expand
Visit Profile
Inactive member.
Member does not subscribe to this thread.
Old Account!
If this is your account, sign in to activate web presence data (sign in quarterly to keep active). Alternatively, you can subscribe to our monthly eMag with a valid email address.
Web Presence Hidden.
Once above is taken care of, full Profile content will display including back links, about me, my message, custom Profile html, social networking links, message board signature, company profile, etc.

Post ID #8356 (Level 1.2)  Reply to 8327
Reply Posted 11/20/2002 6:39:00 AM
Location=Las Vegas, NV USA 
Joined=18 years ago   MB Posts=442   KB Posts=19  
Cerverza
bcn
Thanks
But I can┤t add new objects because I┤m doing a class and it┤s for my job;
When I spoke about loss quality I wanted to say that I want more or less the same quality that gives me the photoshop when strecht a bmp.
If I compare the two qualities(photoshop/delphi) there┤s a lot of difference.
If anybody could help me I would be very grateful!!
Anyway thanks to you.
 Posted 18 years ago (Thread Starter)
Comment Quote
About Cerverza -Collapse +Expand
Visit Profile
Membership pending.
Member subscribes to this thread but email is NOT VERIFIED.
Email Not Verified!
Once email is verified, we will review and approve the account.
Web Presence Hidden.
Once above is taken care of, full Profile content will display including back links, about me, my message, custom Profile html, social networking links, message board signature, company profile, etc.

Post ID #8355 (Level 1.3)  Reply to 8327
Reply Posted 11/20/2002 2:02:00 AM
Location=bcn  
Joined=18 years ago   MB Posts=2  

Revive Thread!

Add a comment to revive this old thread and make this archived thread more useful.

Write a Comment...
Full Editor
...
Sign in...

If you are a member, Sign In. Or, you can Create a Free account now.


Anonymous Post (text-only, no HTML):

Enter your name and security key.

Your Name:
Security key = P125A1
Enter key:
Icon: A Post    Thread    Idea    Important!    Cool    Sad    No    Yes    Includes a Link...   
Thread #8327 Counter
1334
Since 4/2/2008
Go ahead!   Use Us! Call: 916-726-5675  Or visit our new sales site: 
www.prestwood.com


©1995-2020 Prestwood IT Solutions.   [Security & Privacy]