[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Delphi XE10 Round Image

Posted on 2016-08-23
2
Medium Priority
?
470 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 38

Accepted Solution

by:
Geert Gruwez earned 2000 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
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…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

650 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