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 : Wednesday, July 18, 2007 6:28:04 AM(UTC)
simone75

Groups: Registered
Posts: 6


i'd like to fill OCR Zones with transparent background colors, for examples i want red for title zones, yellow for flow text zones and green for Graphics zones.

Can you send me an example in C# for leadtools v.15?

Thanks.

 

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 : Wednesday, July 18, 2007 11:49:55 PM(UTC)
Maen Hasan

Groups: Registered, Tech Support
Posts: 1,326

Was thanked: 1 time(s) in 1 post(s)

Hello,

You can draw a transparent rectangle on the zone that you want by using the following code:
+-------------+
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
Dim G As Graphics
Dim Clr As Color

Dim ZoneLeft, ZoneTop, ZoneWidth, ZoneHeight As Integer
' Zone dimensions
ZoneLeft = 300
ZoneTop = 300
ZoneWidth = 300
ZoneHeight = 300

Const ALPHA As Byte = 128
G = RasterImageViewer1.Image.CreateGdiPlusGraphics().Graphics

clr = Color.FromArgb(ALPHA, 0, 0, 100)
G.FillRectangle(New SolidBrush(Clr), New RectangleF(ZoneLeft, ZoneTop, ZoneWidth, ZoneHeight))
+-------------+

Please let me know if this helps.

Thanks,
Maen Badwan
LEADTOOLS Technical Support
 
#3 Posted : Thursday, July 19, 2007 3:18:16 AM(UTC)
simone75

Groups: Registered
Posts: 6


your code is correctly executed but nothing happens.
i've tried your code to the OCR Demo adding a menu item that exec your sample code after a zone is manually selected.

Can you give me more info?

Thanks

Simone

 
#4 Posted : Sunday, July 22, 2007 4:33:47 AM(UTC)
Maen Hasan

Groups: Registered, Tech Support
Posts: 1,326

Was thanked: 1 time(s) in 1 post(s)

Hello,

Since you are testing this issue using the C# OCR demo, you need to use the following code to draw the rectangle on the Zone:
+----------------+
private void menuItem1_Click(object sender, EventArgs e)
{

RasterImage img = _viewer.Image.Clone();
Graphics G = img.CreateGdiPlusGraphics().Graphics;
          
Color Clr;

int RectLeft, RectTop, RectWidth, RectHeight;
const Byte ALPHA = 128;
RasterDocumentZoneData  _zoneData = _rasterEngine.GetZone(0, 0);

RectLeft = _zoneData.Rectangle.Left-1;
RectTop = _zoneData.Rectangle.Top-1;
RectWidth = _zoneData.Rectangle.Width+2;
RectHeight = _zoneData.Rectangle.Height+2;
          

Clr = Color.FromArgb(ALPHA, 0, 0, 100);
G.PageUnit = GraphicsUnit.Pixel;
if (G.IsVisible(new RectangleF(RectLeft, RectTop, RectWidth, RectHeight)))
{
G.FillRectangle(new SolidBrush(Clr), new RectangleF(RectLeft, RectTop, RectWidth, RectHeight));
               
_rasterEngine.LockPage(0, true);
_rasterEngine.UpdatePage(img, 0);
_rasterEngine.LockPage(0, false);
               
UpdateViewedPage();
}
+----------------+

Please let me know if this helps.

Thanks,
Maen Badwan
LEADTOOLS Technical Support
 
#5 Posted : Monday, July 23, 2007 12:26:56 AM(UTC)
simone75

Groups: Registered
Posts: 6


Now it works fine but i lost the focus to the OCR Zone. I want the focus in the zone when i click on it and i want to change its dimensions like in OCR Demo.

Can you help me?

Thanks

 
#6 Posted : Tuesday, July 24, 2007 1:00:46 AM(UTC)
Maen Hasan

Groups: Registered, Tech Support
Posts: 1,326

Was thanked: 1 time(s) in 1 post(s)

Hello,

Try to use the following code:
-----------------------------------
const Byte ALPHA = 128;

RasterImage img = _viewer.Image.Clone();
Graphics G = img.CreateGdiPlusGraphics().Graphics;
Rectangle rc = new Rectangle(new Point(0,0),_viewer.Image.ImageSize);
Color Clr;
Clr = Color.FromArgb(ALPHA, 0, 0, 100);
int RectLeft, RectTop, RectWidth, RectHeight;
                     
int index = _rasterEngine.SelectedZoneIndex;
RasterDocumentZoneData  _zoneData = _rasterEngine.GetZone(0, index);
           
RectLeft = _zoneData.Rectangle.Left-1;
RectTop = _zoneData.Rectangle.Top-1;
RectWidth = _zoneData.Rectangle.Width+2;
RectHeight = _zoneData.Rectangle.Height+2;         

G.PageUnit = GraphicsUnit.Pixel;
            
if (G.IsVisible(new RectangleF(RectLeft, RectTop, RectWidth, RectHeight)))
{
G.FillRectangle(new SolidBrush(Clr), new RectangleF(RectLeft, RectTop, RectWidth, RectHeight));                
               
_rasterEngine.LockPage(0, true);
_rasterEngine.UpdatePage(img, 0);
_rasterEngine.LockPage(0, false);
                                
_viewer.DrawPage = false;
_rasterEngine.ActivePage = 0;
_viewer.DrawPage = true;
               
_rasterEngine.FindZones(0, rc);
               
_viewer.Refresh();  
               
_rasterEngine.SelectZone(G, 0, index, true);
}
-----------------------------------

Thanks,
Maen Badwan
LEADTOOLS Technical Support
 
#7 Posted : Tuesday, July 24, 2007 5:24:56 AM(UTC)
simone75

Groups: Registered
Posts: 6


the last raw of your code is wrong because  after the findzones() method is called the index of the zones change so the instruction:

_rasterEngine.SelectZone(G, 0, index, true);

doesn't give the original selected zone but a zone with that index.

 I tried to change your code in:

Rectangle rc = _zoneData.Rectangle;

and

_rasterEngine.SelectZone(G, 0, 0, true);

so only the zone in the rc coordinates(equals to original selected zone) should be selected but it doesn't work properly because a strange zone is selected.

Have you any idea?

Thanks

 
#8 Posted : Wednesday, July 25, 2007 10:04:38 PM(UTC)
Maen Hasan

Groups: Registered, Tech Support
Posts: 1,326

Was thanked: 1 time(s) in 1 post(s)

Hello,

I checked the code and it works correctly.

If you feel that there is a problem in the index of the selected zone, you can use the same code that you are using to select the zone, but you can use the SelectZoneByPoint method instead of SelectZone method as follows:
-----------------------------
Rectangle rc = _zoneData.Rectangle;
_rasterEngine.SelectZoneByPoint(G,0,new Point(rc.Left, rc.Top));   
-----------------------------

Please let me know if this helps.

Thanks,
Maen Badwan
LEADTOOLS Technical Support
 
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.088 seconds.