comparison Core/Images/ImageAccessor.cpp @ 2861:9b4251721f22

ImageAccessor now non-copyable
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 05 Oct 2018 17:46:02 +0200
parents 89b789366596
children 0f07bdae0805
comparison
equal deleted inserted replaced
2857:482631e4e290 2861:9b4251721f22
245 buffer.Flatten(target); 245 buffer.Flatten(target);
246 } 246 }
247 247
248 248
249 249
250 ImageAccessor ImageAccessor::GetRegion(unsigned int x, 250 void ImageAccessor::GetRegion(ImageAccessor& accessor,
251 unsigned int y, 251 unsigned int x,
252 unsigned int width, 252 unsigned int y,
253 unsigned int height) const 253 unsigned int width,
254 unsigned int height) const
254 { 255 {
255 if (x + width > width_ || 256 if (x + width > width_ ||
256 y + height > height_) 257 y + height > height_)
257 { 258 {
258 throw OrthancException(ErrorCode_ParameterOutOfRange); 259 throw OrthancException(ErrorCode_ParameterOutOfRange);
259 } 260 }
260 261
261 ImageAccessor result;
262
263 if (width == 0 || 262 if (width == 0 ||
264 height == 0) 263 height == 0)
265 { 264 {
266 result.AssignWritable(format_, 0, 0, 0, NULL); 265 accessor.AssignWritable(format_, 0, 0, 0, NULL);
267 } 266 }
268 else 267 else
269 { 268 {
270 uint8_t* p = (buffer_ + 269 uint8_t* p = (buffer_ +
271 y * pitch_ + 270 y * pitch_ +
272 x * GetBytesPerPixel()); 271 x * GetBytesPerPixel());
273 272
274 if (readOnly_) 273 if (readOnly_)
275 { 274 {
276 result.AssignReadOnly(format_, width, height, pitch_, p); 275 accessor.AssignReadOnly(format_, width, height, pitch_, p);
277 } 276 }
278 else 277 else
279 { 278 {
280 result.AssignWritable(format_, width, height, pitch_, p); 279 accessor.AssignWritable(format_, width, height, pitch_, p);
281 } 280 }
282 } 281 }
283
284 return result;
285 } 282 }
286 283
287 284
288 void ImageAccessor::SetFormat(PixelFormat format) 285 void ImageAccessor::SetFormat(PixelFormat format)
289 { 286 {