comparison Framework/Viewport/CairoSurface.cpp @ 43:e4acd5f331f3

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