Tesseract  3.02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
svshowim.cpp
Go to the documentation of this file.
1 // Copyright 2006 Google Inc. All Rights Reserved.
2 // Author: <rays@google.com> (Ray Smith)
3 //
4 
5 #ifdef HAVE_CONFIG_H
6 #include "config_auto.h"
7 #endif
8 
9 #ifndef GRAPHICS_DISABLED
10 #include "allheaders.h"
11 
12 #include "svshowim.h"
13 #include "scrollview.h"
14 
15 // Override of a tesseract function to display an image in a window.
16 // This function redirects the display to ScrollView instead of the
17 // stubbed-out functions in tesseract.
18 
19 void sv_show_sub_image(IMAGE* source, // Image to show.
20  inT32 xstart, // Start image coords.
21  inT32 ystart,
22  inT32 xext, // Size of rectangle to show.
23  inT32 yext,
24  ScrollView* window, // Window to draw in.
25  inT32 xpos, // Place to show bottom-left.
26  inT32 ypos) { // Y position.
27  Pix* pix;
28  if (xstart != 0 || ystart != 0 ||
29  xext != source->get_xsize() || yext != source->get_ysize()) {
30  IMAGE sub_im;
31  sub_im.create(xext, yext, source->get_bpp());
32  copy_sub_image(source, xstart, ystart, xext, yext, &sub_im, 0, 0, false);
33  pix = sub_im.ToPix();
34  } else {
35  pix = source->ToPix();
36  }
37  window->Image(pix, xpos, window->TranslateYCoordinate(yext) + ypos);
38  pixDestroy(&pix);
39 }
40 
41 #endif // GRAPHICS_DISABLED
42