Beatmup
crop.h
Go to the documentation of this file.
1 /*
2  Beatmup image and signal processing library
3  Copyright (C) 2019, lnstadrum
4 
5  This program is free software: you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation, either version 3 of the License, or
8  (at your option) any later version.
9 
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18 
19 #pragma once
20 #include "../parallelism.h"
21 #include "../geometry.h"
22 #include "abstract_bitmap.h"
23 
24 namespace Beatmup {
25 
26  /**
27  A task to clip images on CPU.
28  */
29  class Crop : public AbstractTask, private BitmapContentLock {
30  private:
31  AbstractBitmap *input, *output; //!< input and output bitmaps
32  IntPoint outOrigin; //!< origin on output bitmap
33  IntRectangle cropRect; //!< clip rect on input bitmap
34  protected:
35  virtual bool process(TaskThread&);
37  virtual void afterProcessing(ThreadIndex, GraphicPipeline*, bool);
38  public:
39  Crop();
40 
41  ThreadIndex getMaxThreads() const { return 1; }
42 
45 
46  /**
47  Sets crop rectangle in input bitmap
48  */
50 
51  /**
52  Sets top-left position of the clip rectangle in output bitmap
53  */
55 
56  /**
57  Checks if everything is fitted to make cropping
58  */
59  bool isFit() const;
60 
61  /**
62  Copies out a specified rect of a bitmap into another bitmap
63  */
65  };
66 }
A very basic class for any image.
Task: an operation that can be executed by multiple threads in parallel.
Definition: parallelism.h:90
Makes sure the bitmap content is accessible within an image processing task.
Definition: content_lock.h:34
A task to clip images on CPU.
Definition: crop.h:29
virtual bool process(TaskThread &)
Executes the task on CPU within a given thread.
Definition: crop.cpp:71
IntRectangle cropRect
clip rect on input bitmap
Definition: crop.h:33
void setOutput(AbstractBitmap *output)
Definition: crop.cpp:103
virtual void afterProcessing(ThreadIndex, GraphicPipeline *, bool)
Instruction called after the task is executed.
Definition: crop.cpp:93
static AbstractBitmap * run(AbstractBitmap &bitmap, IntRectangle clipRect)
Copies out a specified rect of a bitmap into another bitmap.
Definition: crop.cpp:130
IntPoint outOrigin
origin on output bitmap
Definition: crop.h:32
void setOutputOrigin(IntPoint)
Sets top-left position of the clip rectangle in output bitmap.
Definition: crop.cpp:113
bool isFit() const
Checks if everything is fitted to make cropping.
Definition: crop.cpp:118
AbstractBitmap * input
Definition: crop.h:31
virtual void beforeProcessing(ThreadIndex, ProcessingTarget target, GraphicPipeline *)
Instruction called before the task is executed.
Definition: crop.cpp:77
void setCropRect(IntRectangle)
Sets crop rectangle in input bitmap.
Definition: crop.cpp:108
ThreadIndex getMaxThreads() const
Gives the upper limint on the number of threads the task may be performed by.
Definition: crop.h:41
AbstractBitmap * output
input and output bitmaps
Definition: crop.h:31
void setInput(AbstractBitmap *input)
Definition: crop.cpp:98
Internal low-level GPU control API.
Definition: pipeline.h:33
Thread executing tasks.
Definition: parallelism.h:154
unsigned char ThreadIndex
number of threads / thread index
Definition: parallelism.h:68
ProcessingTarget
Definition: basic_types.h:55
Beatmup::InternalBitmap * bitmap