Beatmup
bitmap.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 
21 #include <jni.h>
22 
23 #include <android/bitmap.h>
24 
26 #include <core/context.h>
27 
28 namespace Beatmup {
29  namespace Android {
30 
31  /**
32  Wrapper of Android.Graphics.Bitmap object
33  */
34  class Bitmap : public AbstractBitmap {
35  private:
36  jobject bitmap; //!< java object representing the bitmap
37  JavaVM *jvm; //!< java environment
38 
39  void *lockedPixels; //!< pixel buffer; available only after calling lockPixelData()
42 
43  AndroidBitmapInfo getInfo() const;
44 
45  JNIEnv *getEnv() const;
46 
47  void lockPixelData();
48 
49  void unlockPixelData();
50 
51  public:
52  /**
53  Creates the bitmap from Android Bitmap java object
54  */
56 
57  ~Bitmap();
58 
59  const PixelFormat getPixelFormat() const;
60 
61  const int getWidth() const;
62 
63  const int getHeight() const;
64 
65  const pixbyte* getData(int x, int y) const;
66  pixbyte* getData(int x, int y);
67 
68  const msize getMemorySize() const;
69  };
70 
71  }
72 }
A very basic class for any image.
Wrapper of Android.Graphics.Bitmap object.
Definition: bitmap.h:34
JNIEnv * getEnv() const
Definition: bitmap.cpp:28
Bitmap(Beatmup::Context &, JNIEnv *, jobject)
Creates the bitmap from Android Bitmap java object.
const int getWidth() const
Width of the texture in pixels.
Definition: bitmap.cpp:82
const PixelFormat getPixelFormat() const
Pixel format of the bitmap.
Definition: bitmap.cpp:65
const msize getMemorySize() const
Bitmap size in bytes.
Definition: bitmap.cpp:132
void * lockedPixels
pixel buffer; available only after calling lockPixelData()
Definition: bitmap.h:39
JavaVM * jvm
java environment
Definition: bitmap.h:37
PixelFormat lockedPixelFormat
Definition: bitmap.h:41
AndroidBitmapInfo getInfo() const
Definition: bitmap.cpp:56
jobject bitmap
java object representing the bitmap
Definition: bitmap.h:36
const pixbyte * getData(int x, int y) const
Returns a pointer to given pixel.
Definition: bitmap.cpp:114
void unlockPixelData()
Unlocks access to the CPU memory buffer containing pixel data.
Definition: bitmap.cpp:107
void lockPixelData()
Locks access to the CPU memory buffer containing pixel data.
Definition: bitmap.cpp:96
const int getHeight() const
Height of the texture in pixels.
Definition: bitmap.cpp:89
Basic class: task and memory management, any kind of static data.
Definition: context.h:59
uint32_t msize
memory size
Definition: basic_types.h:30
uint8_t pixbyte
Definition: basic_types.h:34
JNIEnv jobject
jobject jlong jint jint y
jobject jlong jint x