|
|
|
start date: Thu, 28 Jun 2007 14:38:32 -0700,
posted on: microsoft.public.dotnet.framework.drawing
back
| Thread Index |
|
1
Steve Wood
|
|
2
Michael C
|
|
3
Steve Wood
|
|
4
Michael C
|
|
5
Steve Wood
|
|
6
Steve Wood
|
|
7
Steve Wood
|
|
8
active
|
|
9
Steve Wood
|
|
10
active
|
|
11
Steve Wood
|
|
12
active
|
|
13
Steve Wood
|
|
14
Michael C
|
|
15
Steve Wood
|
Selecting a region/rectangle and saving it as a TIFF for Imaging O
The following performs excellent OCR on my image using the Microsoft Office
Document Imaging class (MODI):
Dim miDoc As MODI.Document
Dim miImage As MODI.Image 'System.Drawing.Image object
Dim miImageLayout As MODI.ILayout
Dim tmpStr As String
miDoc.Create("C:\test.tif")
miDoc.OCR()
miImage = miDoc.Images.Item(0)
miImageLayout = miImage.Layout
tmpStr = miImageLayout.Text
Debug.Print(tmpStr)
However, there are graphics in the image which the OCR attempts to convert
into text. In fact, very little of the image contains the text I want...and
that text is spread out in different areas of the image. So, instead of
performing a huge OCR over the entire document then trying to sift through
the garbage to get what I want I would like to use Visual Basic to select
rectangles or regions of the image perhaps using the System.Drawing.Image
class, or PictureBox control, or whatever, and save that selected rectangle
as a TIFF file which I can then load up in the Imaging.Document class and
perform the OCR on just the text that I want.
Basically, I'm looking for a class that will allow me to specify the 4
corners of a rectangle or one corner plus height and width of a
system.drawing.image and select that portion of the image to create a new
system.drawing.image which I can then save as a Tiff to be loaded into the
MODI for OCR.
Date:Thu, 28 Jun 2007 14:38:32 -0700
Author:
|
Re: Selecting a region/rectangle and saving it as a TIFF for Imaging O
"Steve Wood" wrote in message
news:53FDD35E-3FB1-4841-A08F-6763685998CB@microsoft.com...
> Basically, I'm looking for a class that will allow me to specify the 4
> corners of a rectangle or one corner plus height and width of a
> system.drawing.image and select that portion of the image to create a new
> system.drawing.image which I can then save as a Tiff to be loaded into the
> MODI for OCR.
You should be using the Bitmap class instead of Image. Create a new bitmap
and just use a graphics object to drive the areas you want from the first
bitmap onto the second, eg:
dim bitmap as Bitmap
bitmap = new Bitmap(100,100)
dim g as Graphics
g = Graphics.FromImage(bitmap)
g.DrawImage(OriginalBitmap, etc)
g.dispose.
bitmap.save()
Date:Fri, 29 Jun 2007 10:29:24 +1000
Author:
|
Re: Selecting a region/rectangle and saving it as a TIFF for Imagi
Ah...THANKS...that DrawImage() method is powerful! But, I'm having problems
with errors when dealing with these object. I don't know how they work
together. If I use the same filename then I get an exception. Now I'm
getting a memory corrupted error "Attempted to read or write protected
memory. This is often an indication that other memory is corrupt." at the 2nd
time I call "tmpStr = miImageLayout.Text". I don't see anything wrong with
my code...there must be some unusual way that these objects need to be coded
in order for them to work properly. So, I still need help with these objects.
Dim bitmapOrig As Bitmap
Dim bitmap As Bitmap
Dim g As Graphics
Dim rect As Rectangle
bitmapOrig = New Bitmap(1600, 1200)
bitmapOrig = My.Computer.Clipboard.GetImage()
bitmap = New Bitmap(480, 28)
g = Graphics.FromImage(bitmap)
rect = New Rectangle(0, 0, 480, 28)
g.DrawImage(bitmapOrig, rect, 480, 125, 480, 28, GraphicsUnit.Pixel)
rect = Nothing
g.Dispose()
g = Nothing
bitmap.Save("tmp.tif", Drawing.Imaging.ImageFormat.Tiff)
bitmap.Dispose()
bitmap = Nothing
miDoc = New MODI.Document
miDoc.Create("tmp.tif")
miImage = miDoc.Images.Item(0)
miImage.OCR()
miImageLayout = miImage.Layout
tmpStr = miImageLayout.Text
miDoc.Images.Remove(miImage)
miImageLayout = Nothing
miImage = Nothing
Debug.Print(tmpStr)
bitmap = New Bitmap(400, 24)
g = Graphics.FromImage(bitmap)
rect = New Rectangle(0, 0, 400, 24)
g.DrawImage(bitmapOrig, rect, 508, 251, 400, 24, GraphicsUnit.Pixel)
g.Dispose()
g = Nothing
bitmap.Save("tmp2.tif", Drawing.Imaging.ImageFormat.Tiff)
bitmap.Dispose()
miDoc.Create("tmp2.tif")
miImage = miDoc.Images.Item(0)
miImage.OCR()
miImageLayout = miImage.Layout
tmpStr = miImageLayout.Text
miImageLayout = Nothing
miImage = Nothing
miDoc.Close()
miDoc = Nothing
Debug.Print(tmpStr)
Stop
Date:Thu, 28 Jun 2007 21:08:03 -0700
Author:
|
Re: Selecting a region/rectangle and saving it as a TIFF for Imagi
"Steve Wood" wrote in message
news:163CE457-1704-4706-9109-C47AB78CFCEF@microsoft.com...
> Ah...THANKS...that DrawImage() method is powerful! But, I'm having
> problems
> with errors when dealing with these object. I don't know how they work
> together. If I use the same filename then I get an exception. Now I'm
> getting a memory corrupted error "Attempted to read or write protected
> memory. This is often an indication that other memory is corrupt." at the
> 2nd
> time I call "tmpStr = miImageLayout.Text". I don't see anything wrong
> with
> my code...there must be some unusual way that these objects need to be
> coded
> in order for them to work properly. So, I still need help with these
> objects.
For some reason GDI+ locks an image file when you open it with a Bitmap
object. You can't save another bitmap object over the same filename unless
you dispose of the first Bitmap first. If you then pass that filename to
another object then you must ensure BOTH bitmaps have been disposed first.
Date:Fri, 29 Jun 2007 14:39:09 +1000
Author:
|
Re: Selecting a region/rectangle and saving it as a TIFF for Imagi
OK...I've got a serious problem now. I rebooted after several memory errors
and up came a notice that the Administrator has selected that CD and DVD
drives be unusable. And, I did no such thing...I'm the administrator! I
can't see anywhere to get them working again. Driver Manager is fine. I
don't see them in the computer manager, and I don't see anyway to add them to
it.
Now what? I'd rather not reinstall the operating system since I have like
100 programs on this computer and it was working like magic. In fact this is
the first incident I have had with this computer since I built it over 1-1/2
years ago.
Date:Thu, 28 Jun 2007 21:36:00 -0700
Author:
|
Re: Selecting a region/rectangle and saving it as a TIFF for Imagi
"Steve Wood" wrote in message
news:794ABA68-28DB-47C4-8449-A6190AD1C131@microsoft.com...
> OK...I've got a serious problem now. I rebooted after several memory
> errors
> and up came a notice that the Administrator has selected that CD and DVD
> drives be unusable. And, I did no such thing...I'm the administrator! I
> can't see anywhere to get them working again. Driver Manager is fine. I
> don't see them in the computer manager, and I don't see anyway to add them
> to
> it.
>
> Now what? I'd rather not reinstall the operating system since I have like
> 100 programs on this computer and it was working like magic. In fact this
> is
> the first incident I have had with this computer since I built it over
> 1-1/2
> years ago.
That's not really a question for here but try removing the drives under
devicemanager and detect them again.
Date:Fri, 29 Jun 2007 15:08:58 +1000
Author:
|
Re: Selecting a region/rectangle and saving it as a TIFF for Imagi
Thanks, but now I can't even see them in explorer...it got worse. Where
should I ask about this?
"Michael C" wrote:
> "Steve Wood" wrote in message
> news:794ABA68-28DB-47C4-8449-A6190AD1C131@microsoft.com...
> > OK...I've got a serious problem now. I rebooted after several memory
> > errors
> > and up came a notice that the Administrator has selected that CD and DVD
> > drives be unusable. And, I did no such thing...I'm the administrator! I
> > can't see anywhere to get them working again. Driver Manager is fine. I
> > don't see them in the computer manager, and I don't see anyway to add them
> > to
> > it.
> >
> > Now what? I'd rather not reinstall the operating system since I have like
> > 100 programs on this computer and it was working like magic. In fact this
> > is
> > the first incident I have had with this computer since I built it over
> > 1-1/2
> > years ago.
>
> That's not really a question for here but try removing the drives under
> devicemanager and detect them again.
>
>
>
Date:Fri, 29 Jun 2007 00:50:00 -0700
Author:
|
Re: Selecting a region/rectangle and saving it as a TIFF for Imagi
"Michael C" wrote:
>
> For some reason GDI+ locks an image file when you open it with a Bitmap
> object. You can't save another bitmap object over the same filename unless
> you dispose of the first Bitmap first. If you then pass that filename to
> another object then you must ensure BOTH bitmaps have been disposed first.
>
I don't mind file locking...it's a good programming tool. I did include my
code and I am fairly sure that I have completely released everything...does
DoEvents() still work in .net? How can I make sure everything is freed?
And, doesn't it seem likely that this is a huge bug in the drawing class? It
should free up resources when I tell it to, and it not be hacking my computer
system! Where do I report this malicious bug?
Date:Fri, 29 Jun 2007 00:54:01 -0700
Author:
|
Re: Selecting a region/rectangle and saving it as a TIFF for Imagi
OK...I'm still having serious problems with these classes. I am getting an
access violation the 2nd time I call "tmpStr = miImageLayout.Text". I am
giving the classes involved plenty of suggestions that they should clean up
before I use them again. I don't see anything wrong with what I'm doing.
Here's my code:
Dim miDoc As MODI.Document
Dim miImage As MODI.Image
Dim miImageLayout As MODI.ILayout
Dim tmpStr As String
Dim bitmapOrig As Bitmap
Dim bitmap As Bitmap
Dim g As Graphics
Dim rect As Rectangle
miDoc = New MODI.Document
bitmapOrig = New Bitmap(1600, 1200)
bitmapOrig = My.Computer.Clipboard.GetImage()
bitmap = New Bitmap(480, 28)
g = Graphics.FromImage(bitmap)
rect = New Rectangle(0, 0, 480, 28)
g.DrawImage(bitmapOrig, rect, 480, 125, 480, 28, GraphicsUnit.Pixel)
rect = Nothing
g.Dispose()
g = Nothing
bitmap.Save("tmp.tif", Drawing.Imaging.ImageFormat.Tiff)
bitmap.Dispose()
bitmap = Nothing
miDoc.Create("tmp.tif")
miImage = miDoc.Images.Item(0)
miImage.OCR()
miImageLayout = miImage.Layout
tmpStr = miImageLayout.Text 'Access Violation Here!
miImageLayout = Nothing
miImage = Nothing
miDoc.Close()
Debug.Print(tmpStr)
My.Application.DoEvents()
Stop
bitmap = New Bitmap(400, 24)
g = Graphics.FromImage(bitmap)
rect = New Rectangle(0, 0, 400, 24)
g.DrawImage(bitmapOrig, rect, 508, 251, 400, 24, GraphicsUnit.Pixel)
g.Dispose()
g = Nothing
bitmap.Save("tmp2.tif", Drawing.Imaging.ImageFormat.Tiff)
bitmap.Dispose()
miDoc.Create("tmp2.tif")
miImage = miDoc.Images.Item(0)
miImage.OCR()
miImageLayout = miImage.Layout
tmpStr = miImageLayout.Text
miImageLayout = Nothing
miImage = Nothing
miDoc.Close()
miDoc = Nothing
Debug.Print(tmpStr)
Stop
"Steve Wood" wrote:
> "Michael C" wrote:
> >
> > For some reason GDI+ locks an image file when you open it with a Bitmap
> > object. You can't save another bitmap object over the same filename unless
> > you dispose of the first Bitmap first. If you then pass that filename to
> > another object then you must ensure BOTH bitmaps have been disposed first.
> >
>
> I don't mind file locking...it's a good programming tool. I did include my
> code and I am fairly sure that I have completely released everything...does
> DoEvents() still work in .net? How can I make sure everything is freed?
> And, doesn't it seem likely that this is a huge bug in the drawing class? It
> should free up resources when I tell it to, and it not be hacking my computer
> system! Where do I report this malicious bug?
Date:Fri, 29 Jun 2007 08:48:02 -0700
Author:
|
Re: Selecting a region/rectangle and saving it as a TIFF for Imagi
I've tried everything now...I even created a class library to contain the
MODI, bitmap, and graphics classes and call it from a release executable just
to make sure the debugger wasn't interfering. No dice...same error...one or
more of these classes have a serious memory leak or sink.
I cannot proceed in this project if I am only being allowed to perform OCR
on one image and then if I try to do a second one malicious code is hacking
my computer system and disabling my resources. Is there another Microsoft
class available to perform OCR?
"Steve Wood" wrote:
> OK...I'm still having serious problems with these classes. I am getting an
> access violation the 2nd time I call "tmpStr = miImageLayout.Text". I am
> giving the classes involved plenty of suggestions that they should clean up
> before I use them again. I don't see anything wrong with what I'm doing.
> Here's my code:
>
> Dim miDoc As MODI.Document
> Dim miImage As MODI.Image
> Dim miImageLayout As MODI.ILayout
> Dim tmpStr As String
> Dim bitmapOrig As Bitmap
> Dim bitmap As Bitmap
> Dim g As Graphics
> Dim rect As Rectangle
>
> miDoc = New MODI.Document
>
> bitmapOrig = New Bitmap(1600, 1200)
> bitmapOrig = My.Computer.Clipboard.GetImage()
> bitmap = New Bitmap(480, 28)
> g = Graphics.FromImage(bitmap)
> rect = New Rectangle(0, 0, 480, 28)
> g.DrawImage(bitmapOrig, rect, 480, 125, 480, 28, GraphicsUnit.Pixel)
> rect = Nothing
> g.Dispose()
> g = Nothing
> bitmap.Save("tmp.tif", Drawing.Imaging.ImageFormat.Tiff)
> bitmap.Dispose()
> bitmap = Nothing
> miDoc.Create("tmp.tif")
> miImage = miDoc.Images.Item(0)
> miImage.OCR()
> miImageLayout = miImage.Layout
> tmpStr = miImageLayout.Text 'Access Violation Here!
> miImageLayout = Nothing
> miImage = Nothing
> miDoc.Close()
> Debug.Print(tmpStr)
> My.Application.DoEvents()
> Stop
>
> bitmap = New Bitmap(400, 24)
> g = Graphics.FromImage(bitmap)
> rect = New Rectangle(0, 0, 400, 24)
> g.DrawImage(bitmapOrig, rect, 508, 251, 400, 24, GraphicsUnit.Pixel)
> g.Dispose()
> g = Nothing
> bitmap.Save("tmp2.tif", Drawing.Imaging.ImageFormat.Tiff)
> bitmap.Dispose()
> miDoc.Create("tmp2.tif")
> miImage = miDoc.Images.Item(0)
> miImage.OCR()
> miImageLayout = miImage.Layout
> tmpStr = miImageLayout.Text
> miImageLayout = Nothing
> miImage = Nothing
> miDoc.Close()
> miDoc = Nothing
> Debug.Print(tmpStr)
> Stop
>
>
>
>
> "Steve Wood" wrote:
>
> > "Michael C" wrote:
> > >
> > > For some reason GDI+ locks an image file when you open it with a Bitmap
> > > object. You can't save another bitmap object over the same filename unless
> > > you dispose of the first Bitmap first. If you then pass that filename to
> > > another object then you must ensure BOTH bitmaps have been disposed first.
> > >
> >
> > I don't mind file locking...it's a good programming tool. I did include my
> > code and I am fairly sure that I have completely released everything...does
> > DoEvents() still work in .net? How can I make sure everything is freed?
> > And, doesn't it seem likely that this is a huge bug in the drawing class? It
> > should free up resources when I tell it to, and it not be hacking my computer
> > system! Where do I report this malicious bug?
Date:Fri, 29 Jun 2007 11:08:05 -0700
Author:
|
Re: Selecting a region/rectangle and saving it as a TIFF for Imagi
Steve,
I want to play around with your code but I need to know something first.
After running the code are you having trouble with your system even after
rebooting?
Thanks
"Steve Wood" wrote in message
news:55106FFF-8622-43E3-864A-1C08A3D7B629@microsoft.com...
> I've tried everything now...I even created a class library to contain the
> MODI, bitmap, and graphics classes and call it from a release executable
> just
> to make sure the debugger wasn't interfering. No dice...same error...one
> or
> more of these classes have a serious memory leak or sink.
>
> I cannot proceed in this project if I am only being allowed to perform OCR
> on one image and then if I try to do a second one malicious code is
> hacking
> my computer system and disabling my resources. Is there another Microsoft
> class available to perform OCR?
>
> "Steve Wood" wrote:
>
>> OK...I'm still having serious problems with these classes. I am getting
>> an
>> access violation the 2nd time I call "tmpStr = miImageLayout.Text". I am
>> giving the classes involved plenty of suggestions that they should clean
>> up
>> before I use them again. I don't see anything wrong with what I'm doing.
>> Here's my code:
>>
>> Dim miDoc As MODI.Document
>> Dim miImage As MODI.Image
>> Dim miImageLayout As MODI.ILayout
>> Dim tmpStr As String
>> Dim bitmapOrig As Bitmap
>> Dim bitmap As Bitmap
>> Dim g As Graphics
>> Dim rect As Rectangle
>>
>> miDoc = New MODI.Document
>>
>> bitmapOrig = New Bitmap(1600, 1200)
>> bitmapOrig = My.Computer.Clipboard.GetImage()
>> bitmap = New Bitmap(480, 28)
>> g = Graphics.FromImage(bitmap)
>> rect = New Rectangle(0, 0, 480, 28)
>> g.DrawImage(bitmapOrig, rect, 480, 125, 480, 28, GraphicsUnit.Pixel)
>> rect = Nothing
>> g.Dispose()
>> g = Nothing
>> bitmap.Save("tmp.tif", Drawing.Imaging.ImageFormat.Tiff)
>> bitmap.Dispose()
>> bitmap = Nothing
>> miDoc.Create("tmp.tif")
>> miImage = miDoc.Images.Item(0)
>> miImage.OCR()
>> miImageLayout = miImage.Layout
>> tmpStr = miImageLayout.Text 'Access Violation Here!
>> miImageLayout = Nothing
>> miImage = Nothing
>> miDoc.Close()
>> Debug.Print(tmpStr)
>> My.Application.DoEvents()
>> Stop
>>
>> bitmap = New Bitmap(400, 24)
>> g = Graphics.FromImage(bitmap)
>> rect = New Rectangle(0, 0, 400, 24)
>> g.DrawImage(bitmapOrig, rect, 508, 251, 400, 24, GraphicsUnit.Pixel)
>> g.Dispose()
>> g = Nothing
>> bitmap.Save("tmp2.tif", Drawing.Imaging.ImageFormat.Tiff)
>> bitmap.Dispose()
>> miDoc.Create("tmp2.tif")
>> miImage = miDoc.Images.Item(0)
>> miImage.OCR()
>> miImageLayout = miImage.Layout
>> tmpStr = miImageLayout.Text
>> miImageLayout = Nothing
>> miImage = Nothing
>> miDoc.Close()
>> miDoc = Nothing
>> Debug.Print(tmpStr)
>> Stop
>>
>>
>>
>>
>> "Steve Wood" wrote:
>>
>> > "Michael C" wrote:
>> > >
>> > > For some reason GDI+ locks an image file when you open it with a
>> > > Bitmap
>> > > object. You can't save another bitmap object over the same filename
>> > > unless
>> > > you dispose of the first Bitmap first. If you then pass that filename
>> > > to
>> > > another object then you must ensure BOTH bitmaps have been disposed
>> > > first.
>> > >
>> >
>> > I don't mind file locking...it's a good programming tool. I did
>> > include my
>> > code and I am fairly sure that I have completely released
>> > everything...does
>> > DoEvents() still work in .net? How can I make sure everything is
>> > freed?
>> > And, doesn't it seem likely that this is a huge bug in the drawing
>> > class? It
>> > should free up resources when I tell it to, and it not be hacking my
>> > computer
>> > system! Where do I report this malicious bug?
Date:Sat, 30 Jun 2007 09:21:26 -0400
Author:
|
Re: Selecting a region/rectangle and saving it as a TIFF for Imagi
Yes...I've rebooted, ran gpedit.msc from the console and enabled features
that were not enabled and selected for all drives to be visible and
accessible, uninstalled the drivers and reinstalled, etc. The only thing I
haven't done is restore a previous configuration. I still cannot see nor
access my DVD drive or USB flash drive.
What I have figured out is that I am getting the error when the MODI
component fails to perform its OCR. I started playing with different sizes
of portions from my graphics image and can now get it to work on some of the
Tiffs, but not all of them. My next task is to add error recovery which
responds to the error by changing the size of the portion of the image and
trying OCR again...I think that will get me doing what I wanted.
At this point I'm just hoping to get my drives back...I can't even access my
floppy. Luckily my hard drives are still accessible and so is the network.
If you want to play with the code, then it probably would only be beneficial
if you have the image I've been working with. You can download it at
http://Rockn.Shackspace.com/MS/Picture0.tif
Thanks,
Steve
"active" wrote:
> Steve,
>
> I want to play around with your code but I need to know something first.
>
> After running the code are you having trouble with your system even after
> rebooting?
>
>
> Thanks
>
>
> "Steve Wood" wrote in message
> news:55106FFF-8622-43E3-864A-1C08A3D7B629@microsoft.com...
> > I've tried everything now...I even created a class library to contain the
> > MODI, bitmap, and graphics classes and call it from a release executable
> > just
> > to make sure the debugger wasn't interfering. No dice...same error...one
> > or
> > more of these classes have a serious memory leak or sink.
> >
> > I cannot proceed in this project if I am only being allowed to perform OCR
> > on one image and then if I try to do a second one malicious code is
> > hacking
> > my computer system and disabling my resources. Is there another Microsoft
> > class available to perform OCR?
> >
> > "Steve Wood" wrote:
> >
> >> OK...I'm still having serious problems with these classes. I am getting
> >> an
> >> access violation the 2nd time I call "tmpStr = miImageLayout.Text". I am
> >> giving the classes involved plenty of suggestions that they should clean
> >> up
> >> before I use them again. I don't see anything wrong with what I'm doing.
> >> Here's my code:
> >>
> >> Dim miDoc As MODI.Document
> >> Dim miImage As MODI.Image
> >> Dim miImageLayout As MODI.ILayout
> >> Dim tmpStr As String
> >> Dim bitmapOrig As Bitmap
> >> Dim bitmap As Bitmap
> >> Dim g As Graphics
> >> Dim rect As Rectangle
> >>
> >> miDoc = New MODI.Document
> >>
> >> bitmapOrig = New Bitmap(1600, 1200)
> >> bitmapOrig = My.Computer.Clipboard.GetImage()
> >> bitmap = New Bitmap(480, 28)
> >> g = Graphics.FromImage(bitmap)
> >> rect = New Rectangle(0, 0, 480, 28)
> >> g.DrawImage(bitmapOrig, rect, 480, 125, 480, 28, GraphicsUnit.Pixel)
> >> rect = Nothing
> >> g.Dispose()
> >> g = Nothing
> >> bitmap.Save("tmp.tif", Drawing.Imaging.ImageFormat.Tiff)
> >> bitmap.Dispose()
> >> bitmap = Nothing
> >> miDoc.Create("tmp.tif")
> >> miImage = miDoc.Images.Item(0)
> >> miImage.OCR()
> >> miImageLayout = miImage.Layout
> >> tmpStr = miImageLayout.Text 'Access Violation Here!
> >> miImageLayout = Nothing
> >> miImage = Nothing
> >> miDoc.Close()
> >> Debug.Print(tmpStr)
> >> My.Application.DoEvents()
> >> Stop
> >>
> >> bitmap = New Bitmap(400, 24)
> >> g = Graphics.FromImage(bitmap)
> >> rect = New Rectangle(0, 0, 400, 24)
> >> g.DrawImage(bitmapOrig, rect, 508, 251, 400, 24, GraphicsUnit.Pixel)
> >> g.Dispose()
> >> g = Nothing
> >> bitmap.Save("tmp2.tif", Drawing.Imaging.ImageFormat.Tiff)
> >> bitmap.Dispose()
> >> miDoc.Create("tmp2.tif")
> >> miImage = miDoc.Images.Item(0)
> >> miImage.OCR()
> >> miImageLayout = miImage.Layout
> >> tmpStr = miImageLayout.Text
> >> miImageLayout = Nothing
> >> miImage = Nothing
> >> miDoc.Close()
> >> miDoc = Nothing
> >> Debug.Print(tmpStr)
> >> Stop
> >>
> >>
> >>
> >>
> >> "Steve Wood" wrote:
> >>
> >> > "Michael C" wrote:
> >> > >
> >> > > For some reason GDI+ locks an image file when you open it with a
> >> > > Bitmap
> >> > > object. You can't save another bitmap object over the same filename
> >> > > unless
> >> > > you dispose of the first Bitmap first. If you then pass that filename
> >> > > to
> >> > > another object then you must ensure BOTH bitmaps have been disposed
> >> > > first.
> >> > >
> >> >
> >> > I don't mind file locking...it's a good programming tool. I did
> >> > include my
> >> > code and I am fairly sure that I have completely released
> >> > everything...does
> >> > DoEvents() still work in .net? How can I make sure everything is
> >> > freed?
> >> > And, doesn't it seem likely that this is a huge bug in the drawing
> >> > class? It
> >> > should free up resources when I tell it to, and it not be hacking my
> >> > computer
> >> > system! Where do I report this malicious bug?
>
>
>
Date:Sun, 1 Jul 2007 13:16:01 -0700
Author:
|
Re: Selecting a region/rectangle and saving it as a TIFF for Imagi
If your sure your problems stem from that code I think I'll pass.
Sounds serious!
But you seem to be working OK.
Are you sure running that code is what caused the problems?
Thanks for the offer.
"Steve Wood" wrote in message
news:FA277123-D371-45F9-9D65-B8B182E50F0A@microsoft.com...
> Yes...I've rebooted, ran gpedit.msc from the console and enabled features
> that were not enabled and selected for all drives to be visible and
> accessible, uninstalled the drivers and reinstalled, etc. The only thing
> I
> haven't done is restore a previous configuration. I still cannot see nor
> access my DVD drive or USB flash drive.
>
> What I have figured out is that I am getting the error when the MODI
> component fails to perform its OCR. I started playing with different
> sizes
> of portions from my graphics image and can now get it to work on some of
> the
> Tiffs, but not all of them. My next task is to add error recovery which
> responds to the error by changing the size of the portion of the image and
> trying OCR again...I think that will get me doing what I wanted.
>
> At this point I'm just hoping to get my drives back...I can't even access
> my
> floppy. Luckily my hard drives are still accessible and so is the
> network.
> If you want to play with the code, then it probably would only be
> beneficial
> if you have the image I've been working with. You can download it at
> http://Rockn.Shackspace.com/MS/Picture0.tif
>
> Thanks,
> Steve
>
> "active" wrote:
>
>> Steve,
>>
>> I want to play around with your code but I need to know something first.
>>
>> After running the code are you having trouble with your system even after
>> rebooting?
>>
>>
>> Thanks
>>
>>
>> "Steve Wood" wrote in message
>> news:55106FFF-8622-43E3-864A-1C08A3D7B629@microsoft.com...
>> > I've tried everything now...I even created a class library to contain
>> > the
>> > MODI, bitmap, and graphics classes and call it from a release
>> > executable
>> > just
>> > to make sure the debugger wasn't interfering. No dice...same
>> > error...one
>> > or
>> > more of these classes have a serious memory leak or sink.
>> >
>> > I cannot proceed in this project if I am only being allowed to perform
>> > OCR
>> > on one image and then if I try to do a second one malicious code is
>> > hacking
>> > my computer system and disabling my resources. Is there another
>> > Microsoft
>> > class available to perform OCR?
>> >
>> > "Steve Wood" wrote:
>> >
>> >> OK...I'm still having serious problems with these classes. I am
>> >> getting
>> >> an
>> >> access violation the 2nd time I call "tmpStr = miImageLayout.Text". I
>> >> am
>> >> giving the classes involved plenty of suggestions that they should
>> >> clean
>> >> up
>> >> before I use them again. I don't see anything wrong with what I'm
>> >> doing.
>> >> Here's my code:
>> >>
>> >> Dim miDoc As MODI.Document
>> >> Dim miImage As MODI.Image
>> >> Dim miImageLayout As MODI.ILayout
>> >> Dim tmpStr As String
>> >> Dim bitmapOrig As Bitmap
>> >> Dim bitmap As Bitmap
>> >> Dim g As Graphics
>> >> Dim rect As Rectangle
>> >>
>> >> miDoc = New MODI.Document
>> >>
>> >> bitmapOrig = New Bitmap(1600, 1200)
>> >> bitmapOrig = My.Computer.Clipboard.GetImage()
>> >> bitmap = New Bitmap(480, 28)
>> >> g = Graphics.FromImage(bitmap)
>> >> rect = New Rectangle(0, 0, 480, 28)
>> >> g.DrawImage(bitmapOrig, rect, 480, 125, 480, 28, GraphicsUnit.Pixel)
>> >> rect = Nothing
>> >> g.Dispose()
>> >> g = Nothing
>> >> bitmap.Save("tmp.tif", Drawing.Imaging.ImageFormat.Tiff)
>> >> bitmap.Dispose()
>> >> bitmap = Nothing
>> >> miDoc.Create("tmp.tif")
>> >> miImage = miDoc.Images.Item(0)
>> >> miImage.OCR()
>> >> miImageLayout = miImage.Layout
>> >> tmpStr = miImageLayout.Text 'Access Violation Here!
>> >> miImageLayout = Nothing
>> >> miImage = Nothing
>> >> miDoc.Close()
>> >> Debug.Print(tmpStr)
>> >> My.Application.DoEvents()
>> >> Stop
>> >>
>> >> bitmap = New Bitmap(400, 24)
>> >> g = Graphics.FromImage(bitmap)
>> >> rect = New Rectangle(0, 0, 400, 24)
>> >> g.DrawImage(bitmapOrig, rect, 508, 251, 400, 24, GraphicsUnit.Pixel)
>> >> g.Dispose()
>> >> g = Nothing
>> >> bitmap.Save("tmp2.tif", Drawing.Imaging.ImageFormat.Tiff)
>> >> bitmap.Dispose()
>> >> miDoc.Create("tmp2.tif")
>> >> miImage = miDoc.Images.Item(0)
>> >> miImage.OCR()
>> >> miImageLayout = miImage.Layout
>> >> tmpStr = miImageLayout.Text
>> >> miImageLayout = Nothing
>> >> miImage = Nothing
>> >> miDoc.Close()
>> >> miDoc = Nothing
>> >> Debug.Print(tmpStr)
>> >> Stop
>> >>
>> >>
>> >>
>> >>
>> >> "Steve Wood" wrote:
>> >>
>> >> > "Michael C" wrote:
>> >> > >
>> >> > > For some reason GDI+ locks an image file when you open it with a
>> >> > > Bitmap
>> >> > > object. You can't save another bitmap object over the same
>> >> > > filename
>> >> > > unless
>> >> > > you dispose of the first Bitmap first. If you then pass that
>> >> > > filename
>> >> > > to
>> >> > > another object then you must ensure BOTH bitmaps have been
>> >> > > disposed
>> >> > > first.
>> >> > >
>> >> >
>> >> > I don't mind file locking...it's a good programming tool. I did
>> >> > include my
>> >> > code and I am fairly sure that I have completely released
>> >> > everything...does
>> >> > DoEvents() still work in .net? How can I make sure everything is
>> >> > freed?
>> >> > And, doesn't it seem likely that this is a huge bug in the drawing
>> >> > class? It
>> >> > should free up resources when I tell it to, and it not be hacking my
>> >> > computer
>> >> > system! Where do I report this malicious bug?
>>
>>
>>
Date:Sun, 1 Jul 2007 18:26:15 -0400
Author:
|
Re: Selecting a region/rectangle and saving it as a TIFF for Imagi
Yes I'm sure that the problem was related to the errors I was getting. It is
most likely that the debugger got locked up and committed the attrocity that
I'm now facing as it gets an admin account that has total control over the
system. The global admin account which I'm using should have overridden it,
but it is not. The code might be OK, but the classes are reporting problems
if the OCR should fail, which leads to the debugger locking up, which leads
to rebooting, which lead me to losing my DVD and flash drive access.
"active" wrote:
> If your sure your problems stem from that code I think I'll pass.
> Sounds serious!
> But you seem to be working OK.
> Are you sure running that code is what caused the problems?
>
> Thanks for the offer.
>
>
>
> "Steve Wood" wrote in message
> news:FA277123-D371-45F9-9D65-B8B182E50F0A@microsoft.com...
> > Yes...I've rebooted, ran gpedit.msc from the console and enabled features
> > that were not enabled and selected for all drives to be visible and
> > accessible, uninstalled the drivers and reinstalled, etc. The only thing
> > I
> > haven't done is restore a previous configuration. I still cannot see nor
> > access my DVD drive or USB flash drive.
> >
> > What I have figured out is that I am getting the error when the MODI
> > component fails to perform its OCR. I started playing with different
> > sizes
> > of portions from my graphics image and can now get it to work on some of
> > the
> > Tiffs, but not all of them. My next task is to add error recovery which
> > responds to the error by changing the size of the portion of the image and
> > trying OCR again...I think that will get me doing what I wanted.
> >
> > At this point I'm just hoping to get my drives back...I can't even access
> > my
> > floppy. Luckily my hard drives are still accessible and so is the
> > network.
> > If you want to play with the code, then it probably would only be
> > beneficial
> > if you have the image I've been working with. You can download it at
> > http://Rockn.Shackspace.com/MS/Picture0.tif
> >
> > Thanks,
> > Steve
> >
> > "active" wrote:
> >
> >> Steve,
> >>
> >> I want to play around with your code but I need to know something first.
> >>
> >> After running the code are you having trouble with your system even after
> >> rebooting?
> >>
> >>
> >> Thanks
> >>
> >>
> >> "Steve Wood" wrote in message
> >> news:55106FFF-8622-43E3-864A-1C08A3D7B629@microsoft.com...
> >> > I've tried everything now...I even created a class library to contain
> >> > the
> >> > MODI, bitmap, and graphics classes and call it from a release
> >> > executable
> >> > just
> >> > to make sure the debugger wasn't interfering. No dice...same
> >> > error...one
> >> > or
> >> > more of these classes have a serious memory leak or sink.
> >> >
> >> > I cannot proceed in this project if I am only being allowed to perform
> >> > OCR
> >> > on one image and then if I try to do a second one malicious code is
> >> > hacking
> >> > my computer system and disabling my resources. Is there another
> >> > Microsoft
> >> > class available to perform OCR?
> >> >
> >> > "Steve Wood" wrote:
> >> >
> >> >> OK...I'm still having serious problems with these classes. I am
> >> >> getting
> >> >> an
> >> >> access violation the 2nd time I call "tmpStr = miImageLayout.Text". I
> >> >> am
> >> >> giving the classes involved plenty of suggestions that they should
> >> >> clean
> >> >> up
> >> >> before I use them again. I don't see anything wrong with what I'm
> >> >> doing.
> >> >> Here's my code:
> >> >>
> >> >> Dim miDoc As MODI.Document
> >> >> Dim miImage As MODI.Image
> >> >> Dim miImageLayout As MODI.ILayout
> >> >> Dim tmpStr As String
> >> >> Dim bitmapOrig As Bitmap
> >> >> Dim bitmap As Bitmap
> >> >> Dim g As Graphics
> >> >> Dim rect As Rectangle
> >> >>
> >> >> miDoc = New MODI.Document
> >> >>
> >> >> bitmapOrig = New Bitmap(1600, 1200)
> >> >> bitmapOrig = My.Computer.Clipboard.GetImage()
> >> >> bitmap = New Bitmap(480, 28)
> >> >> g = Graphics.FromImage(bitmap)
> >> >> rect = New Rectangle(0, 0, 480, 28)
> >> >> g.DrawImage(bitmapOrig, rect, 480, 125, 480, 28, GraphicsUnit.Pixel)
> >> >> rect = Nothing
> >> >> g.Dispose()
> >> >> g = Nothing
> >> >> bitmap.Save("tmp.tif", Drawing.Imaging.ImageFormat.Tiff)
> >> >> bitmap.Dispose()
> >> >> bitmap = Nothing
> >> >> miDoc.Create("tmp.tif")
> >> >> miImage = miDoc.Images.Item(0)
> >> >> miImage.OCR()
> >> >> miImageLayout = miImage.Layout
> >> >> tmpStr = miImageLayout.Text 'Access Violation Here!
> >> >> miImageLayout = Nothing
> >> >> miImage = Nothing
> >> >> miDoc.Close()
> >> >> Debug.Print(tmpStr)
> >> >> My.Application.DoEvents()
> >> >> Stop
> >> >>
> >> >> bitmap = New Bitmap(400, 24)
> >> >> g = Graphics.FromImage(bitmap)
> >> >> rect = New Rectangle(0, 0, 400, 24)
> >> >> g.DrawImage(bitmapOrig, rect, 508, 251, 400, 24, GraphicsUnit.Pixel)
> >> >> g.Dispose()
> >> >> g = Nothing
> >> >> bitmap.Save("tmp2.tif", Drawing.Imaging.ImageFormat.Tiff)
> >> >> bitmap.Dispose()
> >> >> miDoc.Create("tmp2.tif")
> >> >> miImage = miDoc.Images.Item(0)
> >> >> miImage.OCR()
> >> >> miImageLayout = miImage.Layout
> >> >> tmpStr = miImageLayout.Text
> >> >> miImageLayout = Nothing
> >> >> miImage = Nothing
> >> >> miDoc.Close()
> >> >> miDoc = Nothing
> >> >> Debug.Print(tmpStr)
> >> >> Stop
> >> >>
> >> >>
> >> >>
> >> >>
> >> >> "Steve Wood" wrote:
> >> >>
> >> >> > "Michael C" wrote:
> >> >> > >
> >> >> > > For some reason GDI+ locks an image file when you open it with a
> >> >> > > Bitmap
> >> >> > > object. You can't save another bitmap object over the same
> >> >> > > filename
> >> >> > > unless
> >> >> > > you dispose of the first Bitmap first. If you then pass that
> >> >> > > filename
> >> >> > > to
> >> >> > > another object then you must ensure BOTH bitmaps have been
> >> >> > > disposed
> >> >> > > first.
> >> >> > >
> >> >> >
> >> >> > I don't mind file locking...it's a good programming tool. I did
> >> >> > include my
> >> >> > code and I am fairly sure that I have completely released
> >> >> > everything...does
> >> >> > DoEvents() still work in .net? How can I make sure everything is
> >> >> > freed?
> >> >> > And, doesn't it seem likely that this is a huge bug in the drawing
> >> >> > class? It
> >> >> > should free up resources when I tell it to, and it not be hacking my
> >> >> > computer
> >> >> > system! Where do I report this malicious bug?
> >>
> >>
> >>
>
>
>
Date:Sun, 1 Jul 2007 18:52:03 -0700
Author:
|
Re: Selecting a region/rectangle and saving it as a TIFF for Imagi
Thanks for the warning
"Steve Wood" wrote in message
news:70497D89-D22F-4C8C-A708-5D1D00B34536@microsoft.com...
> Yes I'm sure that the problem was related to the errors I was getting. It
> is
> most likely that the debugger got locked up and committed the attrocity
> that
> I'm now facing as it gets an admin account that has total control over the
> system. The global admin account which I'm using should have overridden
> it,
> but it is not. The code might be OK, but the classes are reporting
> problems
> if the OCR should fail, which leads to the debugger locking up, which
> leads
> to rebooting, which lead me to losing my DVD and flash drive access.
>
> "active" wrote:
>
>> If your sure your problems stem from that code I think I'll pass.
>> Sounds serious!
>> But you seem to be working OK.
>> Are you sure running that code is what caused the problems?
>>
>> Thanks for the offer.
>>
>>
>>
>> "Steve Wood" wrote in message
>> news:FA277123-D371-45F9-9D65-B8B182E50F0A@microsoft.com...
>> > Yes...I've rebooted, ran gpedit.msc from the console and enabled
>> > features
>> > that were not enabled and selected for all drives to be visible and
>> > accessible, uninstalled the drivers and reinstalled, etc. The only
>> > thing
>> > I
>> > haven't done is restore a previous configuration. I still cannot see
>> > nor
>> > access my DVD drive or USB flash drive.
>> >
>> > What I have figured out is that I am getting the error when the MODI
>> > component fails to perform its OCR. I started playing with different
>> > sizes
>> > of portions from my graphics image and can now get it to work on some
>> > of
>> > the
>> > Tiffs, but not all of them. My next task is to add error recovery
>> > which
>> > responds to the error by changing the size of the portion of the image
>> > and
>> > trying OCR again...I think that will get me doing what I wanted.
>> >
>> > At this point I'm just hoping to get my drives back...I can't even
>> > access
>> > my
>> > floppy. Luckily my hard drives are still accessible and so is the
>> > network.
>> > If you want to play with the code, then it probably would only be
>> > beneficial
>> > if you have the image I've been working with. You can download it at
>> > http://Rockn.Shackspace.com/MS/Picture0.tif
>> >
>> > Thanks,
>> > Steve
>> >
>> > "active" wrote:
>> >
>> >> Steve,
>> >>
>> >> I want to play around with your code but I need to know something
>> >> first.
>> >>
>> >> After running the code are you having trouble with your system even
>> >> after
>> >> rebooting?
>> >>
>> >>
>> >> Thanks
>> >>
>> >>
>> >> "Steve Wood" wrote in message
>> >> news:55106FFF-8622-43E3-864A-1C08A3D7B629@microsoft.com...
>> >> > I've tried everything now...I even created a class library to
>> >> > contain
>> >> > the
>> >> > MODI, bitmap, and graphics classes and call it from a release
>> >> > executable
>> >> > just
>> >> > to make sure the debugger wasn't interfering. No dice...same
>> >> > error...one
>> >> > or
>> >> > more of these classes have a serious memory leak or sink.
>> >> >
>> >> > I cannot proceed in this project if I am only being allowed to
>> >> > perform
>> >> > OCR
>> >> > on one image and then if I try to do a second one malicious code is
>> >> > hacking
>> >> > my computer system and disabling my resources. Is there another
>> >> > Microsoft
>> >> > class available to perform OCR?
>> >> >
>> >> > "Steve Wood" wrote:
>> >> >
>> >> >> OK...I'm still having serious problems with these classes. I am
>> >> >> getting
>> >> >> an
>> >> >> access violation the 2nd time I call "tmpStr = miImageLayout.Text".
>> >> >> I
>> >> >> am
>> >> >> giving the classes involved plenty of suggestions that they should
>> >> >> clean
>> >> >> up
>> >> >> before I use them again. I don't see anything wrong with what I'm
>> >> >> doing.
>> >> >> Here's my code:
>> >> >>
>> >> >> Dim miDoc As MODI.Document
>> >> >> Dim miImage As MODI.Image
>> >> >> Dim miImageLayout As MODI.ILayout
>> >> >> Dim tmpStr As String
>> >> >> Dim bitmapOrig As Bitmap
>> >> >> Dim bitmap As Bitmap
>> >> >> Dim g As Graphics
>> >> >> Dim rect As Rectangle
>> >> >>
>> >> >> miDoc = New MODI.Document
>> >> >>
>> >> >> bitmapOrig = New Bitmap(1600, 1200)
>> >> >> bitmapOrig = My.Computer.Clipboard.GetImage()
>> >> >> bitmap = New Bitmap(480, 28)
>> >> >> g = Graphics.FromImage(bitmap)
>> >> >> rect = New Rectangle(0, 0, 480, 28)
>> >> >> g.DrawImage(bitmapOrig, rect, 480, 125, 480, 28,
>> >> >> GraphicsUnit.Pixel)
>> >> >> rect = Nothing
>> >> >> g.Dispose()
>> >> >> g = Nothing
>> >> >> bitmap.Save("tmp.tif", Drawing.Imaging.ImageFormat.Tiff)
>> >> >> bitmap.Dispose()
>> >> >> bitmap = Nothing
>> >> >> miDoc.Create("tmp.tif")
>> >> >> miImage = miDoc.Images.Item(0)
>> >> >> miImage.OCR()
>> >> >> miImageLayout = miImage.Layout
>> >> >> tmpStr = miImageLayout.Text 'Access Violation Here!
>> >> >> miImageLayout = Nothing
>> >> >> miImage = Nothing
>> >> >> miDoc.Close()
>> >> >> Debug.Print(tmpStr)
>> >> >> My.Application.DoEvents()
>> >> >> Stop
>> >> >>
>> >> >> bitmap = New Bitmap(400, 24)
>> >> >> g = Graphics.FromImage(bitmap)
>> >> >> rect = New Rectangle(0, 0, 400, 24)
>> >> >> g.DrawImage(bitmapOrig, rect, 508, 251, 400, 24,
>> >> >> GraphicsUnit.Pixel)
>> >> >> g.Dispose()
>> >> >> g = Nothing
>> >> >> bitmap.Save("tmp2.tif", Drawing.Imaging.ImageFormat.Tiff)
>> >> >> bitmap.Dispose()
>> >> >> miDoc.Create("tmp2.tif")
>> >> >> miImage = miDoc.Images.Item(0)
>> >> >> miImage.OCR()
>> >> >> miImageLayout = miImage.Layout
>> >> >> tmpStr = miImageLayout.Text
>> >> >> miImageLayout = Nothing
>> >> >> miImage = Nothing
>> >> >> miDoc.Close()
>> >> >> miDoc = Nothing
>> >> >> Debug.Print(tmpStr)
>> >> >> Stop
>> >> >>
>> >> >>
>> >> >>
>> >> >>
>> >> >> "Steve Wood" wrote:
>> >> >>
>> >> >> > "Michael C" wrote:
>> >> >> > >
>> >> >> > > For some reason GDI+ locks an image file when you open it with
>> >> >> > > a
>> >> >> > > Bitmap
>> >> >> > > object. You can't save another bitmap object over the same
>> >> >> > > filename
>> >> >> > > unless
>> >> >> > > you dispose of the first Bitmap first. If you then pass that
>> >> >> > > filename
>> >> >> > > to
>> >> >> > > another object then you must ensure BOTH bitmaps have been
>> >> >> > > disposed
>> >> >> > > first.
>> >> >> > >
>> >> >> >
>> >> >> > I don't mind file locking...it's a good programming tool. I did
>> >> >> > include my
>> >> >> > code and I am fairly sure that I have completely released
>> >> >> > everything...does
>> >> >> > DoEvents() still work in .net? How can I make sure everything is
>> >> >> > freed?
>> >> >> > And, doesn't it seem likely that this is a huge bug in the
>> >> >> > drawing
>> >> >> > class? It
>> >> >> > should free up resources when I tell it to, and it not be hacking
>> >> >> > my
>> >> >> > computer
>> >> >> > system! Where do I report this malicious bug?
>> >>
>> >>
>> >>
>>
>>
>>
Date:Sun, 1 Jul 2007 22:17:44 -0400
Author:
|
|
|