Solved

Delphi XE10 Round Image

Posted on 2016-08-23
2
268 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

690 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