comparison Framework/Viewport/CairoSurface.cpp @ 42:81e2651dca17

sync
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 14 Apr 2017 12:03:25 +0200
parents 7207a407bcd8
children e4acd5f331f3
comparison
equal deleted inserted replaced
41:ed07f4bbf1a8 42:81e2651dca17
75 } 75 }
76 76
77 77
78 CairoSurface::CairoSurface(Orthanc::ImageAccessor& accessor) 78 CairoSurface::CairoSurface(Orthanc::ImageAccessor& accessor)
79 { 79 {
80 printf("Enter\n");
81
80 if (accessor.GetFormat() != Orthanc::PixelFormat_BGRA32) 82 if (accessor.GetFormat() != Orthanc::PixelFormat_BGRA32)
81 { 83 {
84 printf("Error 1\n");
82 throw Orthanc::OrthancException(Orthanc::ErrorCode_IncompatibleImageFormat); 85 throw Orthanc::OrthancException(Orthanc::ErrorCode_IncompatibleImageFormat);
83 } 86 }
84 87
85 width_ = accessor.GetWidth(); 88 width_ = accessor.GetWidth();
86 height_ = accessor.GetHeight(); 89 height_ = accessor.GetHeight();
89 92
90 surface_ = cairo_image_surface_create_for_data 93 surface_ = cairo_image_surface_create_for_data
91 (reinterpret_cast<unsigned char*>(buffer_), CAIRO_FORMAT_RGB24, width_, height_, pitch_); 94 (reinterpret_cast<unsigned char*>(buffer_), CAIRO_FORMAT_RGB24, width_, height_, pitch_);
92 if (!surface_) 95 if (!surface_)
93 { 96 {
97 printf("Error 2\n");
94 // Should never occur 98 // Should never occur
95 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError); 99 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError);
96 } 100 }
97 101
98 if (cairo_surface_status(surface_) != CAIRO_STATUS_SUCCESS) 102 if (cairo_surface_status(surface_) != CAIRO_STATUS_SUCCESS)
99 { 103 {
104 printf("Error 3\n");
100 LOG(ERROR) << "Bad pitch for a Cairo surface"; 105 LOG(ERROR) << "Bad pitch for a Cairo surface";
101 cairo_surface_destroy(surface_); 106 cairo_surface_destroy(surface_);
102 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError); 107 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError);
103 } 108 }
109
110 printf("Success\n");
104 } 111 }
105 112
106 113
107 void CairoSurface::SetSize(unsigned int width, 114 void CairoSurface::SetSize(unsigned int width,
108 unsigned int height) 115 unsigned int height)