MCPcopy Create free account
hub / github.com/LibreSprite/LibreSprite / cropImage

Method cropImage

src/app/cmd/crop_cel.cpp:44–69  ·  view source on GitHub ↗

Crops the cel image leaving the same ID in the image.

Source from the content-addressed store, hash-verified

42
43// Crops the cel image leaving the same ID in the image.
44void CropCel::cropImage(const gfx::Point& origin,
45 const gfx::Rect& bounds)
46{
47 auto cel = this->cel();
48
49 if (bounds != cel->image()->bounds()) {
50 ImageRef image(crop_image(cel->image(),
51 bounds.x, bounds.y,
52 bounds.w, bounds.h,
53 cel->image()->maskColor()));
54 ObjectId id = cel->image()->id();
55 ObjectVersion ver = cel->image()->version();
56
57 cel->image()->setId(NullId);
58 image->setId(id);
59 image->setVersion(ver);
60 image->incrementVersion();
61 cel->data()->setImage(image);
62 cel->incrementVersion();
63 }
64
65 if (cel->data()->position() != origin) {
66 cel->data()->setPosition(origin);
67 cel->incrementVersion();
68 }
69}
70
71} // namespace cmd
72} // namespace app

Callers

nothing calls this directly

Calls 14

crop_imageFunction · 0.85
setVersionMethod · 0.80
incrementVersionMethod · 0.80
celMethod · 0.45
boundsMethod · 0.45
imageMethod · 0.45
maskColorMethod · 0.45
idMethod · 0.45
versionMethod · 0.45
setIdMethod · 0.45
setImageMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected