Hi,

James and Jessica, the question you are asking here are beginner dev
question, not tesseract specific.
If you want to read BMP, TIFF, JPG, PNG images under Windows (native C+
+ or .NET) use GdiPlus.
It's free, well documented and you have a working example with
Tesseract.
In Google "GdiPlus Library" gives you
http://msdn.microsoft.com/en-us/library/ms533798(VS.85).aspx
Always in Google "GdiPlus tutorial" gives you
http://www.codeproject.com/KB/GDI-plus/startinggdiplus.aspx
to read image file (one line of code)
http://www.codeproject.com/KB/GDI-plus/cgdiplusbitmap.aspx
and to use it in C++ tesseract download
http://www.pixel-technology.com/freeware/tessnet2/src.zip
open tessnet2.cpp and look for
tessnet2::Tesseract::PutImage
line 272

Rémi

On Feb 4, 6:25 pm, JamesBaker <[email protected]> wrote:
> Jessicia: I am working towards the same objective, but I have come
> into problems with linking, this code works, but when I call tessdll
> functions I am getting errors with both linking and access violations:
>
> Also, if anyone can help me here as there is very little
> documentation, is this the right method? I have no idea wether or not
> I am grabbing the correct BMP data or not. Do I need the whole MS DIB
> bitmap format: data + header, or just the data?
>
> unsigned char* ScreenCap(int x, int y, int w, int h) //PORT (w,h) ???
> {
>         //int nScreenWidth = GetSystemMetrics(SM_CXSCREEN);
>         //int nScreenHeight = GetSystemMetrics(SM_CYSCREEN);
>
>         int portedX = x * resolution.first.first / resolution.second.first;
>         int portedY = y * resolution.first.second / resolution.second.second;
>
>         HWND hDesktopWnd = GetDesktopWindow();
>         HDC hDesktopDC = GetDC(mtgowin);
>         HDC hCaptureDC = CreateCompatibleDC(hDesktopDC);
>         HBITMAP hCaptureBitmap =CreateCompatibleBitmap(hDesktopDC, w, h);
>         SelectObject(hCaptureDC,hCaptureBitmap);
>         BitBlt(hCaptureDC,0,0,w,h,hDesktopDC, portedX,portedY,SRCCOPY);
>
>         //convert to unsigned char[]
>
>         BITMAPINFO bmpInfo;
>
>         HDC hdc=GetDC(NULL);
>         ZeroMemory(&bmpInfo,sizeof(BITMAPINFO));
>         bmpInfo.bmiHeader.biSize=sizeof(BITMAPINFOHEADER);
>
>         GetDIBits(hdc,hCaptureBitmap,0,0,NULL, &bmpInfo,DIB_RGB_COLORS);
>         //unsigned char* retArray = new unsigned char
> [bmpInfo.bmiHeader.biSizeImage];
>         LPVOID retArray = malloc(bmpInfo.bmiHeader.biSizeImage);
>
>         bmpInfo.bmiHeader.biCompression=BI_RGB;
>         GetDIBits(hdc,hCaptureBitmap,0,bmpInfo.bmiHeader.biHeight, retArray,
> &bmpInfo, DIB_RGB_COLORS);
>
>         ReleaseDC(hDesktopWnd,hDesktopDC);
>         DeleteDC(hCaptureDC);
>         DeleteObject(hCaptureBitmap);
>         if(hdc)     ReleaseDC(NULL,hdc);
>
>         return (unsigned char*)retArray;
>
> }
>
> On Feb 4, 8:39 am, Jessica <[email protected]> wrote:
>
> > At first I was using tessdll.
> > I need to convert a bitmap that I have in memory to an unsigned char
> > *.
> > I used LockBit, then Scan0 on the BitmapData, and I have my unsigned
> > char *.
>
> > Unfortunately this does not work when passed to TessDLL api.
>
> > Do you know how to format the unsigned char * the way tess dll wants
> > it?
>
> > On 4 fév, 14:36, rthomas <[email protected]> wrote:
>
> > > Yes this is a .NET project but the C++ code source is the same for
> > > GdiPlus API.
> > > You can understand how to use LockBit.
>
> > > Remi
>
> > > On Feb 4, 12:58 pm, Jessica <[email protected]> wrote:
>
> > > > Thank you very much for your answer rthomas.
>
> > > > I don't know at all .NET in fact.
> > > > My project is a traditionnal c++ project (windows application). I'd
> > > > like to use the .net assembly in this project.
> > > > Is it possible?
>
> > > > In the link you gave me , apparently you need to use the tessnet2 in
> > > > a .net project. Is it possible to easily switch from a c++ project to
> > > > a .net project? What are the differences?
>
> > > > Thanks!
>
> > > > On 4 fév, 12:07, rthomas <[email protected]> wrote:
>
> > > > > Hi,
>
> > > > > Look tessnet2 source code, It's done with 
> > > > > Gdi+.http://www.pixel-technology.com/freeware/tessnet2/src.zip
>
> > > > > Rémi
>
> > > > > On Feb 4, 10:22 am, Jessica <[email protected]> wrote:
>
> > > > > > Hi,
>
> > > > > > I have a big problem.
> > > > > > I want to ocr screenshots.
>
> > > > > > I am under windows vista, using c++, gdi+
>
> > > > > > I have a Gdiplus::Bitmap, I need to convert it to an unsigned char *
> > > > > > to put it in TessDLLAPI (I'm using tessdll.dll)
>
> > > > > > I used the function LockBits to get a BitmapData and then scan0 to 
> > > > > > get
> > > > > > an unsigned char *
> > > > > > But this does not work!
>
> > > > > > I don't know how to format it.
> > > > > > Could someone help me please?
>
> > > > > > Thank you!- Hide quoted text -
>
> > > > - Show quoted text -
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"tesseract-ocr" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/tesseract-ocr?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to