Solved

Delphi XE10 Round Image

Posted on 2016-08-23
2
75 Views
Last Modified: 2016-09-24
Hi all,

I have searched everywhere and maybe I am looking in the wrong places but does anybody perhaps have code to make a jpg or png image round? I am getting my image from DevExpress webcam control and want to make image round show in image and save to DB.
0
Comment
Question by:DigitalNam
2 Comments
 
LVL 37

Accepted Solution

by:
Geert Gruwez earned 500 total points
ID: 41768252
what do you mean by round ?

clip it to a circle ?
the image itself will also be rectangular
but you can add a border outside the circle

Create a second bitmap with size of the original

Use CreateEllipticRgn to create a circle region within that new bitmap
https://msdn.microsoft.com/en-us/library/dd183496(v=vs.85).aspx

Use SelectClipRgn to exclude the rest of ellips/circle from clipping

Then BrushCopy the original on the new bitmap
and save that new bitmap

You can clip an image like this to any shape you want
Clipping functions:
https://msdn.microsoft.com/en-us/library/dd162464(v=vs.85).aspx

Region functions:
https://msdn.microsoft.com/en-us/library/dd162913(v=vs.85).aspx

Most of these functions are available in the TCanvas methods
like Bitmap.Canvas.BrushCopy

Otherwise it's in the windows unit
0
 
LVL 1

Author Comment

by:DigitalNam
ID: 41769081
Thank you for the info Geert, I had a look at some samples after some links you suggested. I can now make a round image, but I need to anti alias the border and make the center of the image a circle because the sample of the image I make round takes the left top corner.

This is the code that I have. Can you perhaps give your input and point me in the right direction again please.

procedure TForm1.Button1Click(Sender: TObject);
var
  bmp : TBitmap;
  frgn : HRGN;
begin
  bmp := TBitmap.Create;
  fRgn := CreateEllipticRgn (10, 10, 200, 200);
  try
    bmp.LoadFromFile('d:\devtest.bmp');
    Canvas.Brush.Bitmap := bmp;
    PaintRgn(Canvas.Handle,frgn);
    FrameRgn(Canvas.Handle,frgn,Canvas.Brush.Handle,2,2);
  finally
//    Canvas.Brush.Bitmap := null;
    bmp.Free;
  end;
end;

Open in new window

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Using FastMM4... should I enable MMX option? 9 75
Newbie Thread Programming 1 139
Firemonkey android show image from resource ? 1 30
update joined tables 2 26
The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

929 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now