Welcome Guest! To enable all features, please Login or Register.

Notification

Icon
Error

Options
View
Last Go to last post Unread Go to first unread post
#1 Posted : Sunday, July 30, 2006 5:51:26 AM(UTC)

VadimR  
VadimR

Groups: Registered
Posts: 20


Hi,

how to combine a some shapes to region? For example, to  combine there are two intersected polygons by combine mode L_RGN_SETNOT?

Best regards, Vadim.

 

Try the latest version of LEADTOOLS for free for 60 days by downloading the evaluation: https://www.leadtools.com/downloads

Wanna join the discussion? Login to your LEADTOOLS Support accountor Register a new forum account.

#2 Posted : Tuesday, August 1, 2006 6:50:34 AM(UTC)

GregR  
GregR

Groups: Registered, Tech Support, Administrators
Posts: 764


Which environment are you using?  Since you referenced L_RGN_SETNOT, I am assuming the API.

SETNOT will create a region containing everything except the new region.  If you want to make multiple regions combine and add together, use L_RGN_OR.  The helpfile has a good article explaining with pictures what each combine mode does.  Based on the subject of your post, it seems like L_RGN_OR is what you need to use.

Does this answer your question?  If not, please reply and explain your problem with more details.
 
#3 Posted : Tuesday, August 1, 2006 8:41:43 PM(UTC)

VadimR  
VadimR

Groups: Registered
Posts: 20


I use version 14.5 and need to code how get combination , for example, of the some polygons with  the classes LBitmapRgn, LBitmapWindow.
 
#4 Posted : Wednesday, August 2, 2006 10:13:01 AM(UTC)

GregR  
GregR

Groups: Registered, Tech Support, Administrators
Posts: 764


Are you programming with LEAD's C++ Class Library?

I'm not sure exactly what you mean by "how get combination".  Once I know what you are trying to do and what environment you are using (Class lib, API, COM, .NET, etc.) I will be able to answer your question more specifically once I can understand your problem.

Since it now sounds like you're using the C++ Class Library, I'll give you some places to look in the help-file:
"Creating a Bitmap Region"
LBitmapRgn::SetRgnCombineMode
LBitmapRgn::SetRgnPolygon

 
#5 Posted : Wednesday, August 2, 2006 8:41:26 PM(UTC)

VadimR  
VadimR

Groups: Registered
Posts: 20


Hi,

I am programming with LEAD's C++ Class Library. I can't to write code for creating a region as an intersection of there are two polygons with combine method L_RGN_AND.Help me, please.

 

 

 
#6 Posted : Thursday, August 3, 2006 10:12:05 AM(UTC)

GregR  
GregR

Groups: Registered, Tech Support, Administrators
Posts: 764


Create a function in your viewer class, and use the Region() macro with your LBitmapWindow object to draw some regions.  The example below creates two regions, one triangle and one square, and combines them using L_RGN_AND.  m_Wnd is my LBitmapWindow object.  You have to create an array of POINTs, create a pointer to that array and pass it into the SetRgnPolygon()  function.  Each time this function (or any other SetRgn???() method) is called, it will create a new region and add it to the existing region based on what you set your combine mode to.  Keep in mind that if there are no previously existing regions, the whole bitmap counts as a region, so if you use something like L_RGN_OR for your first region, it will make the whole bitmap a region.

    //create array of points for a triangular region
    POINT points1[3];
    POINT L_FAR *pPoints1 = points1;
    points1[0].x = 50;
    points1[0].y = 50;
    points1[1].x = 150;
    points1[1].y = 50;
    points1[2].x = 100;
    points1[2].y = 200;

    //create array of points for a square region
    POINT points2[4];
    POINT L_FAR *pPoints2 = points2;
    points2[0].x = 0;
    points2[0].y = 0;
    points2[1].x = 0;
    points2[1].y = 150;
    points2[2].x = 150;
    points2[2].y = 150;
    points2[3].x = 150;
    points2[3].y = 0;

    //Set the combine mode and create the regions
    m_Wnd.Region()->SetRgnCombineMode(L_RGN_AND);
    m_Wnd.Region()->SetRgnPolygon(pPoints1,3,L_POLY_WINDING);
    m_Wnd.Region()->SetRgnPolygon(pPoints2,4,L_POLY_WINDING);

Let me know if this helps.
 
#7 Posted : Saturday, August 5, 2006 11:53:58 PM(UTC)

VadimR  
VadimR

Groups: Registered
Posts: 20


Hi, Greg!

Thank for answer. In first, member function Region() is not described in the help in  the follow classes: LBase, LBitmapBase, LBitmap, LBitmap- Window. In second, region that appears it is not combination of the two regions. The last region will be shown only.

Suncerely,

Vadim

 

 
#8 Posted : Monday, August 7, 2006 3:47:23 AM(UTC)

GregR  
GregR

Groups: Registered, Tech Support, Administrators
Posts: 764


Vadim,

Region() is not a member function and that is why it is not documented as one.  It is a Map Macro and is documented in the help article "Bitmap Class Map Macros". 

You are probably not using the correct Combine Mode if you are not getting the desired results.  If you are only seeing the last region, then you are probably using L_RGN_SET.  For a very detailed list of the combine modes to use with SetRgnCombineMode(), see the help article "Creating a Bitmap Region".  This article outlines each combine mode and shows pictures of what results you would get when adding multiple regions with the specific combine mode.
 
#9 Posted : Wednesday, August 9, 2006 2:05:44 AM(UTC)

VadimR  
VadimR

Groups: Registered
Posts: 20


Dear, Greg!

Thank you for last answer. I tested a similiar code. This code is shown below 

 RECT rClnA;

GetDlgItem(IDC_RGNFRAME)->GetClientRect(&rClnA);

POINT points1[3];
POINT  *pPoints1 = points1;

 points1[0].x = rClnA.left;
 points1[0].y = rClnA.bottom;
 points1[1].x = rClnA.right;
 points1[1].y = (rClnA.bottom + rClnA.top)/2;
 points1[2].x = rClnA.left;
 points1[2].y = rClnA.top;

//create array of points for a square region
POINT points2[4];
POINT L_FAR *pPoints2 = points2;

points2[0].x = rClnA.right;
points2[0].y = rClnA.bottom;
points2[1].x = (rClnA.right - rClnA.left)/3 +rClnA.left;
points2[1].y = rClnA.bottom;
points2[2].x = (rClnA.right - rClnA.left)/3+rClnA.left;
points2[2].y = rClnA.top;
points2[3].x = rClnA.right;
points2[3].y = rClnA.top;

//Set the combine mode and create the regions
m_Image.Region()->SetRgnCombineMode(L_RGN_SET);
m_Image.Region()->SetRgnPolygon(pPoints1,3,L_POLY_WINDING);

m_Image.Region()->SetRgnCombineMode(L_RGN_AND);
m_Image.Region()->SetRgnPolygon(pPoints2,4,L_POLY_WINDING);

Result is not correct. Because, at least,  the resulted region must be simmetrical. Unfortunetely, I can't uppload a screenshot and drawing, because I get error message

 
#10 Posted : Wednesday, August 9, 2006 4:14:26 AM(UTC)

GregR  
GregR

Groups: Registered, Tech Support, Administrators
Posts: 764


The code looks right, but I'm not sure that the math is correct.  Perhaps there is something else going on before or afterwards that is not working properly.  For example, I do not know what m_Image is, as well as  Please send me a simple working project that is causing this problem for you so I can look at it in context. 

You can attach screenshots as well, but you can only post a .zip file to our forum, and that is why you have been getting errors.  When I have these I'll understand better what is going on elsewhere in your code and what you are hoping to acheive.
 
#11 Posted : Wednesday, August 9, 2006 9:36:29 PM(UTC)

VadimR  
VadimR

Groups: Registered
Posts: 20


 GregR wrote:The code looks right, but I'm not sure that the math is correct.  Perhaps there is something else going on before or afterwards that is not working properly.  For example, I do not know what m_Image is, as well as  Please send me a simple working project that is causing this problem for you so I can look at it in context. 

You can attach screenshots as well, but you can only post a .zip file to our forum, and that is why you have been getting errors.  When I have these I'll understand better what is going on elsewhere in your code and what you are hoping to acheive.

================================================

Hi, Greg!

I send a snippet  with  full function description. And description of  class CUserBitmapWin . Because I use the variable of this type in function      void CRegionDlg::OnSetTwoReg().

 

class CRegionDlg : public CDialog
{
// Construction
public:
 CUserBitmapWin  m_Image;

}

void CRegionDlg::OnSetTwoReg()
{

 RECT rClnA;

 GetDlgItem(IDC_RGNFRM)->GetClientRect(&rClnA);

    POINT points1[3];
    POINT  *pPoints1 = points1;

 points1[0].x = rClnA.left;
 points1[0].y = rClnA.bottom;
 points1[1].x = rClnA.right;
 points1[1].y = (rClnA.bottom + rClnA.top)/2;
 points1[2].x = rClnA.left;
 points1[2].y = rClnA.top;

    //create array of points for a square region
    POINT points2[4];
    POINT L_FAR *pPoints2 = points2;

 points2[0].x = rClnA.right;
 points2[0].y = rClnA.bottom;
 points2[1].x = (rClnA.right - rClnA.left)/3 +rClnA.left;
 points2[1].y = rClnA.bottom;
 points2[2].x = (rClnA.right - rClnA.left)/3+rClnA.left;
 points2[2].y = rClnA.top;
 points2[3].x = rClnA.right;
 points2[3].y = rClnA.top;

    //Set the combine mode and create the regions
   // m_Image.Region()->SetRgnCombineMode(L_RGN_SET);
 m_Image.Region()->SetRgnCombineMode(L_RGN_AND);
    m_Image.Region()->SetRgnPolygon(pPoints1,3,L_POLY_WINDING);
    m_Image.Region()->SetRgnPolygon(pPoints2,4,L_POLY_WINDING);

}

================================================

class CUserBitmapWin : public LBitmapWindow 
{
public:
    CProgressCtrl* Progress;
 HWND hWinWnd;
 CMsgData m_msd;

 int StatusCallBack (int nPercentComplete);
 LRESULT MsgProcCallBack(HWND hWnd,UINT uMsg,WPARAM wParam,LPARAM lParam);

 CUserBitmapWin();
 virtual ~CUserBitmapWin();
};

================================================

#include "stdafx.h"
#include "UserBitmapWin.h"


#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

CUserBitmapWin::CUserBitmapWin()
{
 Progress = NULL;
 hWinWnd = NULL;
}

CUserBitmapWin::~CUserBitmapWin()
{

}

int CUserBitmapWin::StatusCallBack (int nPercentComplete)
{
 if (!Progress) return FAILURE;

 Progress->SetPos(nPercentComplete);
 return SUCCESS;
}

LRESULT  CUserBitmapWin::MsgProcCallBack(HWND hWnd,UINT uMsg,WPARAM wParam,LPARAM lParam)
{
 COPYDATASTRUCT cd;

 m_msd.Msg = uMsg;
 m_msd.LParam = lParam;
 m_msd.WParam = wParam;

 cd.lpData  = &m_msd;
 cd.cbData = sizeof(m_msd);

 if (!hWinWnd) return NULL;

 if ( uMsg == WM_LBUTTONUP || uMsg == WM_LBUTTONDOWN || uMsg == WM_MOUSEMOVE)
  SendMessage(hWinWnd,WM_COPYDATA,0, (LPARAM) &cd);


 return LBitmapWindow::MsgProcCallBack(hWnd,uMsg, wParam ,lParam);
}

Sincerely, Vadim

File Attachment(s):
result.zip (33kb) downloaded 31 time(s).
 
#12 Posted : Thursday, August 10, 2006 5:02:33 AM(UTC)

GregR  
GregR

Groups: Registered, Tech Support, Administrators
Posts: 764


Vadim,

That's what I thought might've been happening based on your screenshots.  The actual result looks like you are grabbing an area larger than the bitmap itself.  Perhaps the line GetDlgItem(IDC_RGNFRM)->GetClientRect(&rClnA); is your problem here.  I do not know exactly what IDC_RGNFRM is in your project since you only sent me a snippet, but I'm assuming it's your whole form.  This would cause rClnA to be wider than the bitmap and is not giving you the region you desire.  Make sure rClnA is the same dimensions of your bitmap.  Try hard-coding the values you know are correct first and then try to dynamically pass it the rectangle you think is the bitmap.  I cannot know what exactly will fix this since you did not send me your project, but just a snippet.  Please send your project if you still have trouble after these suggestions.
 
#13 Posted : Sunday, August 13, 2006 2:00:47 AM(UTC)

VadimR  
VadimR

Groups: Registered
Posts: 20


Hi, Greg!

Please, to download the project. The image with the region appears after press on button "Set two regions"

Sincerely, Vadim

File Attachment(s):
tstLead.zip (56kb) downloaded 31 time(s).
 
#14 Posted : Monday, August 14, 2006 12:08:17 PM(UTC)

GregR  
GregR

Groups: Registered, Tech Support, Administrators
Posts: 764


Vadim,

I think we've found the problem.  Bitmap coordinates and form coordinates are not necessarily the same system, and regions are added based on bitmap coordinates.  The sample below is an example using bitmap coordinates:

points1[0].x = 0;
points1[0].y = 0;
points1[1].x = m_Image.GetWidth();
points1[1].y = m_Image.GetHeight()/2;
points1[2].x = 0;
points1[2].y = m_Image.GetHeight();

//create array of points for a square region
POINT points2[4];
POINT L_FAR *pPoints2 = points2;

points2[0].x = m_Image.GetWidth();
points2[0].y = m_Image.GetHeight();
points2[1].x = m_Image.GetWidth()/3;
points2[1].y = m_Image.GetHeight();
points2[2].x = m_Image.GetWidth()/3;
points2[2].y = 0;
points2[3].x = m_Image.GetWidth();
points2[3].y = 0;
 
#15 Posted : Wednesday, August 16, 2006 6:25:20 AM(UTC)

VadimR  
VadimR

Groups: Registered
Posts: 20


Hi Greg!

Thank you very much for  help.

Sincerely, Vadim

 
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Powered by YAF.NET | YAF.NET © 2003-2024, Yet Another Forum.NET
This page was generated in 0.174 seconds.