22#include "glChartCanvas.h"
23#include "ocpn_frame.h"
24#include "printout_chart.h"
32void ChartPrintout::DrawPage(wxDC* dc,
int page) {
35 gFrame->GetFocusCanvas()->GetClientSize(&sx, &sy);
45 max_x += (2 * margin_x);
46 max_y += (2 * margin_y);
53 float scale_x = (float)(w / max_x);
54 float scale_y = (float)(h / max_y);
57 float actual_scale = wxMin(scale_x, scale_y);
60 float pos_x = (float)((w - (max_x * actual_scale)) / 2.0);
61 float pos_y = (float)((h - (max_y * actual_scale)) / 2.0);
63 pos_x = wxMax(pos_x, margin_x);
64 pos_y = wxMax(pos_y, margin_y);
67 dc->SetUserScale(actual_scale, actual_scale);
68 dc->SetDeviceOrigin((
long)pos_x, (
long)pos_y);
74 if (m_gl_bmp.IsOk()) {
76 mdc.SelectObject(m_gl_bmp);
77 dc->Blit(0, 0, m_gl_bmp.GetWidth(), m_gl_bmp.GetHeight(), &mdc, 0, 0);
78 mdc.SelectObject(wxNullBitmap);
84 mdc.SelectObject(*(gFrame->GetFocusCanvas()->pscratch_bm));
86 dc->Blit(0, 0, gFrame->GetFocusCanvas()->pscratch_bm->GetWidth(),
87 gFrame->GetFocusCanvas()->pscratch_bm->GetHeight(), &mdc, 0, 0);
89 mdc.SelectObject(wxNullBitmap);
96 int gsx = gFrame->GetFocusCanvas()->GetglCanvas()->GetSize().x;
97 int gsy = gFrame->GetFocusCanvas()->GetglCanvas()->GetSize().y;
99 unsigned char* buffer = (
unsigned char*)malloc(gsx * gsy * 4);
100 glReadPixels(0, 0, gsx, gsy, GL_RGBA, GL_UNSIGNED_BYTE, buffer);
102 unsigned char* e = (
unsigned char*)malloc(gsx * gsy * 3);
105 for (
int p = 0; p < gsx * gsy; p++) {
106 e[3 * p + 0] = buffer[4 * p + 0];
107 e[3 * p + 1] = buffer[4 * p + 1];
108 e[3 * p + 2] = buffer[4 * p + 2];
113 wxImage image(gsx, gsy);
115 wxImage mir_imag = image.Mirror(
false);
116 m_gl_bmp = wxBitmap(mir_imag);
ChartCanvas - Main chart display and interaction component.
void GenerateGLbmp()
In OperGL mode, make the bitmap capture of the screen before the print method starts as to be sure th...