Tesseract  3.02
tesseract-ocr/image/svshowim.cpp
Go to the documentation of this file.
00001 // Copyright 2006 Google Inc. All Rights Reserved.
00002 // Author: <rays@google.com> (Ray Smith)
00003 //
00004 
00005 #ifdef HAVE_CONFIG_H
00006 #include "config_auto.h"
00007 #endif
00008 
00009 #ifndef GRAPHICS_DISABLED
00010 #include "allheaders.h"
00011 
00012 #include "svshowim.h"
00013 #include "scrollview.h"
00014 
00015 // Override of a tesseract function to display an image in a window.
00016 // This function redirects the display to ScrollView instead of the
00017 // stubbed-out functions in tesseract.
00018 
00019 void sv_show_sub_image(IMAGE*    source,         // Image to show.
00020                        inT32     xstart,         // Start image coords.
00021                        inT32     ystart,
00022                        inT32     xext,           // Size of rectangle to show.
00023                        inT32     yext,
00024                        ScrollView*    window,         // Window to draw in.
00025                        inT32     xpos,           // Place to show bottom-left.
00026                        inT32     ypos) {         // Y position.
00027   Pix* pix;
00028   if (xstart != 0 || ystart != 0 ||
00029       xext != source->get_xsize() || yext != source->get_ysize()) {
00030     IMAGE sub_im;
00031     sub_im.create(xext, yext, source->get_bpp());
00032     copy_sub_image(source, xstart, ystart, xext, yext, &sub_im, 0, 0, false);
00033     pix = sub_im.ToPix();
00034   } else {
00035     pix = source->ToPix();
00036   }
00037   window->Image(pix, xpos, window->TranslateYCoordinate(yext) + ypos);
00038   pixDestroy(&pix);
00039 }
00040 
00041 #endif  // GRAPHICS_DISABLED
00042