This topic and its replies were posted before the current version of LEADTOOLS was released and may no longer be applicable.
#1
Posted
:
Thursday, August 7, 2008 6:29:29 PM(UTC)
Groups: Registered
Posts: 13
When I move the rectangle, the color of the area in the rectangle will be changed.
I just do like this:
combine the two bitmaps, one has color, one is grayscale.But I want the processing smooth,real time
hxboxy attached the following image(s):
#2
Posted
:
Friday, August 8, 2008 4:27:51 AM(UTC)
Groups: Guests
Posts: 3,022
Was thanked: 2 time(s) in 2 post(s)
Hello,
Before I can recommended any changes, I need to know a few things.
1. What version of the toolkit are you using?
2. What language are you programming in?
3. What features of the toolkit are you using to implement the above functionality? (what ImageProcessing objects, Annotations, etc.)
#3
Posted
:
Friday, August 8, 2008 4:06:57 PM(UTC)
Groups: Registered
Posts: 13
1. Ver12.1
2. MFC
3. LBitmapRgn
#4
Posted
:
Tuesday, August 12, 2008 10:30:53 AM(UTC)
Groups: Guests
Posts: 3,022
Was thanked: 2 time(s) in 2 post(s)
Since you're using LBitmapRgn, it seems that the drawing of the region would be handled by you. Correct? If not, could you create a small demo (not your whole app) that shows the behavior and attach it to your reply?
#5
Posted
:
Tuesday, August 12, 2008 9:01:30 PM(UTC)
Groups: Registered
Posts: 13
LBitmapRgn Region1(&bmp2, L_RGN_SETNOT);
Region1.SetRgnRect(&Rect);
LBitmap bmpRgn;//
Region1.CreateMaskFromBitmapRgn(&bmpRgn);
bmpRgn.ColorRes(24, CRF_BYTEORDERBGR);
bmpRgn.Combine(&bmp2, 1024, 768);
bmpRgn.GrayScale(8);
bmpRgn.ColorRes(24, CRF_BYTEORDERBGR);
LBitmap bmpColor;
bmpColor.CopyRect(bmp2, Rect);
//
bmpColor.ColorRes(24, CRF_BYTEORDERBGR);
Region1.Free();
if (bmp2.HasRgn())
{
LBitmapRgn rgn(&bmp2);
rgn.Free();
}
if (bmpColor.HasRgn())
{
LBitmapRgn rgn(&bmpColor);
rgn.Free();
}
bmpRgn.Combine(&bmpColor,
(Rect.right - Rect.left), (Rect.bottom - Rect.top),
Rect.left, Rect.top, 0, 0, CB_OP_OR);
//
m_picEdit.Copy(bmpRgn);
bmpColor.Free();
bmpRgn.Free();
#6
Posted
:
Tuesday, August 12, 2008 9:03:47 PM(UTC)
Groups: Registered
Posts: 13
<BLOCKQUOTE><table width="85%"><tr><td class="txt4"><img src="/SupportPortal/cs/Themes/default/images/icon-quote.gif"> <strong>hxboxy wrote:</strong></td></tr><tr><td class="quoteTable"><table width="100%"><tr><td width="100%" valign="top" class="txt4">LBitmapRgn Region1(&bmp2, L_RGN_SETNOT);
Region1.SetRgnRect(&Rect);
LBitmap bmpRgn;//
Region1.CreateMaskFromBitmapRgn(&bmpRgn);
bmpRgn.ColorRes(24, CRF_BYTEORDERBGR);
bmpRgn.Combine(&bmp2, 1024, 768);
bmpRgn.GrayScale(8);
bmpRgn.ColorRes(24, CRF_BYTEORDERBGR);
LBitmap bmpColor;
bmpColor.CopyRect(bmp2, Rect);
//
bmpColor.ColorRes(24, CRF_BYTEORDERBGR);
Region1.Free();
if (bmp2.HasRgn())
{
LBitmapRgn rgn(&bmp2);
rgn.Free();
}
if (bmpColor.HasRgn())
{
LBitmapRgn rgn(&bmpColor);
rgn.Free();
}
bmpRgn.Combine(&bmpColor,
(Rect.Width()), (Rect.Height()),
Rect.left, Rect.top, 0, 0, CB_OP_OR);
//
m_picEdit.Copy(bmpRgn);
bmpColor.Free();
bmpRgn.Free();</td></tr></table></td></tr></table></BLOCKQUOTE>
#7
Posted
:
Wednesday, August 13, 2008 6:27:22 AM(UTC)
Groups: Guests
Posts: 3,022
Was thanked: 2 time(s) in 2 post(s)
How are you moving the rectangle? On a mouse move event?
#8
Posted
:
Wednesday, August 13, 2008 9:30:22 PM(UTC)
Groups: Registered
Posts: 13
Yes!
But I think there must be a better way……
#9
Posted
:
Thursday, August 14, 2008 11:27:36 AM(UTC)
Groups: Guests
Posts: 3,022
Was thanked: 2 time(s) in 2 post(s)
Yeah, I agree. There maybe a way to do it through Win32 API calls, like painting directly on the DC (device context). I'm trying a few things right now to see how it works out.
#10
Posted
:
Monday, August 18, 2008 3:08:55 AM(UTC)
Groups: Registered
Posts: 13
How about that, two bitmap, part of one transparency
#11
Posted
:
Tuesday, August 19, 2008 8:18:32 AM(UTC)
Groups: Guests
Posts: 3,022
Was thanked: 2 time(s) in 2 post(s)
I came up with this: instead of using regions, you combine the image on the fly. Combining image is very fast. You load the image in LBitmapWindow. You load the image in 2 other LBitmap objects, so you will have 3 instances of the image in memory. One of the LBitmap objects will be the original that will never be modified. The LBimtapWindow will house the grayscale version and the second LBitmap object will house the color image.
We'll define those as:
LBitmapWindow mainGrayscale
LBitmap orginalCopy
LBimtap colorCopy
To draw the rectangle the very first time you do: mainGrayscale->Combine(colorCopy, [check help file for these params], CB_OP_ADD | CP_DST_0)
When the user moves the rectangle you take the previous rectangle value and you gray out that previously colored area, then you color in the new area, like so:
mainGrayscale->Combine(originalCopy, [old rect], CB_OP_ADD | CP_DST_0)
mainGrayscale->Combine(colorCopy, [new rect], CB_OP_ADD | CP_DST_0)
This is close to perfect, but you will notice a minor flicker.
I will update your other post with this same information.
#12
Posted
:
Wednesday, August 20, 2008 1:31:31 AM(UTC)
Groups: Registered
Posts: 13
Thanks for the quick response.
That's exaclty what I was looking for. I'll try this approach.
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.