Solved

Delphi XE10 Round Image

Posted on 2016-08-23
2
53 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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

746 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

12 Experts available now in Live!

Get 1:1 Help Now