-
首页
-
C4D R23.110 C++ SDK
BaseBitmap Class Reference
#include <c4d_basebitmap.h>
详细描述
The bitmap class can be used to load, read, draw and save bitmap pictures of various formats.
Bitmaps are organized so that the 2D point
[0,0]
is the top left corner. Be sure to call
Init()
before you attempt to use a newly allocated bitmap.
-
注意
-
Has to be created with
Alloc()
and destroyed with
Free()
。使用
AutoAlloc
to automate the allocation and destruction based on scope.
-
警告
-
Though
BaseBitmap
can work with other bit depths than
24
and
32
, note that only these function support other bit depths:
GetBw()
,
GetBh()
,
GetBt()
,
GetBpz()
,
Init()
, GetLine(), SetLine(),
GetPixelCnt()
,
SetPixelCnt()
,
SetCMAP()
,
AddChannel()
,
RemoveChannel()
,
GetAlphaPixel()
,
SetAlphaPixel()
,
GetInternalChannel()
,
GetChannelCount()
,
GetChannelNum()
To use higher bit depths or multiple channels, see
MultipassBitmap
.
Init
|
static
IMAGERESULT
|
Init
(
BaseBitmap
*&res, const
Filename
&name,
Int32
frame=-1,
Bool
*ismovie=nullptr,
BitmapLoaderPlugin
**loaderplugin=nullptr, const
maxon::Delegate
< void(
Float
progress)> &progressCallback=nullptr)
|
IMAGERESULT
|
Init
(const
Filename
&name,
Int32
frame=-1,
Bool
*ismovie=nullptr)
|
IMAGERESULT
|
Init
(
Int32
x,
Int32
y,
Int32
depth=24,
INITBITMAPFLAGS
flags=
INITBITMAPFLAGS::NONE
)
|
Scaling
|
void
|
ScaleIt
(
BaseBitmap
*dst,
Int32
intens,
Bool
sample,
Bool
nprop) const
|
void
|
ScaleBicubic
(
BaseBitmap
*dst,
Int32
src_xmin,
Int32
src_ymin,
Int32
src_xmax,
Int32
src_ymax,
Int32
dst_xmin,
Int32
dst_ymin,
Int32
dst_xmax,
Int32
dst_ymax) const
|
Drawing
|
void
|
SetPen
(
Int32
r,
Int32
g,
Int32
b)
|
void
|
清零
(
Int32
r,
Int32
g,
Int32
b)
|
void
|
清零
(
Int32
x1,
Int32
y1,
Int32
x2,
Int32
y2,
Int32
r,
Int32
g,
Int32
b)
|
void
|
Line
(
Int32
x1,
Int32
y1,
Int32
x2,
Int32
y2)
|
void
|
Arc
(
Int32
x,
Int32
y,
Float
radius,
Float
angle_start,
Float
angle_end,
Int32
subdiv=32)
|
Get/Set Pixels
|
void
|
GetPixel
(
Int32
x,
Int32
y,
UInt16
*r,
UInt16
*g,
UInt16
*b) const
|
Vector32
|
GetPixelDirect
(
Int32
x,
Int32
y) const
|
Bool
|
SetPixel
(
Int32
x,
Int32
y,
Int32
r,
Int32
g,
Int32
b)
|
void
|
GetAlphaPixel
(
BaseBitmap
*channel,
Int32
x,
Int32
y,
UInt16
*val) const
|
Bool
|
SetAlphaPixel
(
BaseBitmap
*channel,
Int32
x,
Int32
y,
Int32
val)
|
void
|
GetPixelCnt
(
Int32
x,
Int32
y,
Int32
cnt,
UChar
*buffer,
Int32
inc,
COLORMODE
dstmode,
PIXELCNT
flags,
ColorProfileConvert
*conversion=nullptr) const
|
Bool
|
SetPixelCnt
(
Int32
x,
Int32
y,
Int32
cnt,
UChar
*buffer,
Int32
inc,
COLORMODE
srcmode,
PIXELCNT
flags)
|
构造函数 & 析构函数文档编制
◆
BaseBitmap()
◆
~BaseBitmap()
成员函数文档编制
◆
Alloc()
Allocates a bitmap. Destroy the allocated bitmap with
Free()
。使用
AutoAlloc
to automate the allocation and destruction based on scope.
-
返回
-
The allocated bitmap, or
nullptr
if the allocation failed.
◆
Free()
Destructs bitmaps allocated with
Alloc()
。使用
AutoAlloc
to automate the allocation and destruction based on scope.
-
参数
-
[in,out]
|
bm
|
The bitmap to destruct. If the pointer is
nullptr
nothing happens. The pointer is assigned
nullptr
afterwards.
|
◆
Init()
[1/3]
Loads a bitmap file. The format is automatically detected.
-
注意
-
The bitmap class only supports up to
4
channels. Also, most image loaders will only load one alpha channel.
-
参数
-
[out]
|
res
|
Assigned a pointer to a bitmap. The caller owns the pointed bitmap.
|
[in]
|
name
|
A valid filename that can either refer a movie or a picture.
|
[in]
|
frame
|
The frame number to load in a movie.
|
[in]
|
ismovie
|
If not
nullptr
this pointer is assigned
true
if the loaded picture is a movie, otherwise
false
.
|
[in]
|
loaderplugin
|
If not
nullptr
this pointer is assigned a bitmap loader plugin instance of the same type as the loaded bitmap. The caller owns the pointed bitmap loader.
|
[in]
|
progressCallback
|
Callback which is triggered if the loader supports progress reporting. Since R19.
|
-
返回
-
The image result:
IMAGERESULT
◆
Init()
[2/3]
Loads a file into the bitmap. The file format is automatically detected.
-
警告
-
Any previous data in the bitmap object is lost.
-
注意
-
The bitmap class only supports up to
4
channels. Also, most image loaders will only load one alpha channel.
-
参数
-
[in]
|
name
|
A valid filename that can either refer a movie or a picture.
|
[in]
|
frame
|
The frame number to load in a movie.
|
[in]
|
ismovie
|
If not
nullptr
this pointer is assigned
true
if the loaded picture is a movie, otherwise
false
.
|
-
返回
-
The image result:
IMAGERESULT
◆
Init()
[3/3]
Initializes the bitmap to the given [
x
,
y
] dimensions and
depth
.
-
警告
-
Any previous data in the bitmap object is lost.
-
参数
-
[in]
|
x
|
The requested width in pixels (Maximum 16 000 pixels).
|
[in]
|
y
|
The requested height in pixels (Max. 16000 pixels).
|
[in]
|
depth
|
The requested bit depth. The possible values are (
1
,
4
,
8
,
16
,
24
,
32
,
64
,
96
). On some platforms
32
-bit will be used even if
24
is requested, to allow for padding. In this case
GetBt()
will return
32
.
|
[in]
|
flags
|
The initialization flags:
INITBITMAPFLAGS
|
-
返回
-
The image result:
IMAGERESULT
◆
FlushAll()
Resets the bitmap to its initial state and frees allocated memory. Requires a call to
Init()
before the bitmap can be used again.
◆
Save()
Saves the bitmap to a file.
-
参数
-
[in]
|
name
|
A valid filename that can either refer a movie or a picture.
|
[in]
|
format
|
The image format:
FILTER
|
[in]
|
data
|
The additional settings for some formats. MISCSAVER
Can be
nullptr
, which means the same as an empty container. The caller owns the pointed container.
|
[in]
|
savebits
|
A combination of the following flags:
SAVEBIT
|
-
返回
-
The image result:
IMAGERESULT
◆
GetClone()
Copies the bitmap.
-
警告
-
Do not use
GetClone()
in a
NodeData::CopyTo
method. This will cause memory leaks. Use
CopyTo()
instead.
-
返回
-
The cloned bitmap, or
nullptr
if an error occured. The caller owns the pointed bitmap.
◆
GetClonePart()
Copies a part of the bitmap, specified by the rectangle [
x
,
y
] to [
x
+
w
,
y
+
h
].
-
参数
-
[in]
|
x
|
The upper left
X
coordinate of the rectangle.
|
[in]
|
y
|
The upper left
Y
coordinate of the rectangle.
|
[in]
|
w
|
The width of the rectangle.
|
[in]
|
h
|
The height of the rectangle.
|
-
返回
-
The cloned part of the bitmap, or
nullptr
if an error occured. The caller owns the pointed bitmap.
◆
CopyTo()
Copies the bitmap from
*this
to
*dst
.
-
参数
-
[out]
|
dst
|
The bitmap to copy this bitmap to. The caller owns the pointed bitmap.
|
-
返回
-
true
if the bitmap was successfully copied, otherwise
false
.
◆
CopyPartTo()
Copies a part of the bitmap from
*this
to
*dst
.
-
参数
-
[out]
|
dst
|
The bitmap to copy this bitmap to. The caller owns the pointed bitmap.
|
[in]
|
x
|
The
X
position of the part to be copied from
*this
.
|
[in]
|
y
|
The
Y
position of the part to be copied from
*this
.
|
[in]
|
w
|
The width of the part to be copied.
|
[in]
|
h
|
The height of the part to be copied.
|
-
返回
-
true
if the bitmap part was successfully copied, otherwise
false
.
◆
GetBw()
Int32
GetBw
|
(
|
void
|
|
)
|
const
|
Gets the width of the bitmap in pixels. If the bitmap has not been initialized the return value is 0.
-
注意
-
Calling this method is the only way to see if a bitmap passed by
Cinema 4D
or some other source has been initialized.
-
返回
-
The bitmap width in pixels, or
0
if the bitmap is not initialized.
◆
GetBh()
Int32
GetBh
|
(
|
void
|
|
)
|
const
|
Gets the height of the bitmap in pixels.
-
返回
-
The bitmap height in pixels.
◆
GetBt()
Int32
GetBt
|
(
|
void
|
|
)
|
const
|
Gets the number of bits per pixel.
-
返回
-
The number of bits per pixel.
◆
GetBpz()
Int32
GetBpz
|
(
|
void
|
|
)
|
const
|
Gets the number of bytes per line.
-
返回
-
The number of bytes per line.
◆
GetColorMode()
Gets the color mode of the bitmap.
-
返回
-
The color mode:
COLORMODE
◆
ScaleIt()
Scales the bitmap to fit in the destination bitmap and copies it there.
The destination bitmap
dst
needs to be initialized with the destination size before calling this function.
-
参数
-
[out]
|
dst
|
The destination bitmap. The caller owns the pointed bitmap.
|
[in]
|
intens
|
Lets you change brightness of the image (
128
=
50
% brightness,
256
= unchanged).
|
[in]
|
sample
|
若
true
a better scaling algorithm is used, which results in a better quality but a bit slower.
|
[in]
|
nprop
|
Must be
true
if non-proportional scaling is wanted.
|
◆
ScaleBicubic()
Scales the bitmap rectangle [
src_xmin
,
src_ymin
,
src_xmax
,
src_ymax
] to fit in the destination bitmap rectangle [
dst_xmin
,
dst_ymin
,
dst_xmax
,
dst_ymax
] and copies it there.
The scaling, if necessary, is done using Bicubic interpolation.
The destination bitmap
dst
needs to be initialized before calling this function.
-
注意
-
This function can currently only scale down, i.e. the destination needs to be smaller to the source in size.
-
参数
-
[out]
|
dst
|
The destination bitmap. The caller owns the pointed bitmap.
|
[in]
|
src_xmin
|
The source top left X coordinate.
|
[in]
|
src_ymin
|
The source top left Y coordinate.
|
[in]
|
src_xmax
|
The source bottom right X coordinate.
|
[in]
|
src_ymax
|
The source bottom right Y coordinate.
|
[in]
|
dst_xmin
|
The destination top left X coordinate.
|
[in]
|
dst_ymin
|
The destination top left Y coordinate.
|
[in]
|
dst_xmax
|
The destination bottom right X coordinate.
|
[in]
|
dst_ymax
|
The destination bottom right Y coordinate.
|
◆
SetPen()
Sets the color for the following drawing operations.
The range of the parameters is
0
to
255
, where (
255
,
255
,
255
) is white, regardless of the bit depth of the image.
-
注意
-
This method only works with bit depth
24
and
32
.
-
参数
-
[in]
|
r
|
The red component.
|
[in]
|
g
|
The green component.
|
[in]
|
b
|
The blue component.
|
◆
Clear()
[1/2]
Sets all pixels in the bitmap to the color specified by (
r
,
g
,
b
).
The range of the parameters is
0
to
255
, where (
255
,
255
,
255
) is white, regardless of the bit depth of the image.
-
注意
-
This method only works with bit depth
24
and
32
.
-
参数
-
[in]
|
r
|
The red component.
|
[in]
|
g
|
The green component.
|
[in]
|
b
|
The blue component.
|
◆
Clear()
[2/2]
Sets all pixels within the rectangle specified by [
x1
,
y1
] and [
x2
,
y2
] to the color specified by (
r
,
g
,
b
).
The range of the parameters is
0
to
255
, where (
255
,
255
,
255
) is white, regardless of the bit depth of the image.
-
注意
-
This method only works with bit depth
24
and
32
.
-
参数
-
[in]
|
x1
|
The top left X coordinate of the rectangle.
|
[in]
|
y1
|
The top left Y coordinate of the rectangle.
|
[in]
|
x2
|
The bottom right X coordinate of the rectangle.
|
[in]
|
y2
|
The bottom right Y coordinate of the rectangle.
|
[in]
|
r
|
The red component.
|
[in]
|
g
|
The green component.
|
[in]
|
b
|
The blue component.
|
◆
Line()
Draws a line with the current pen color between (
x1
,
y1
) and (
x2
,
y2
).
-
注意
-
This method only works with bit depth
24
and
32
.
-
参数
-
[in]
|
x1
|
The start X coordinate.
|
[in]
|
y1
|
The start Y coordinate.
|
[in]
|
x2
|
The end X coordinate.
|
[in]
|
y2
|
The end Y coordinate.
|
◆
Arc()
Draws an arc (section of a circle) with the current
pen
color at [
x
,
y
].
-
参数
-
[in]
|
x
|
The X coordinate.
|
[in]
|
y
|
The Y coordinate.
|
[in]
|
radius
|
The radius of the ellipse.
|
[in]
|
angle_start
|
The start of the angle in radians.
|
[in]
|
angle_end
|
The end of the angle in radians.
|
[in]
|
subdiv
|
The range between
angle_start
and
angle_end
is divided into
subdiv
line segments.
|
◆
GetPixel()
Gets the color at [
x
,
y
] and assigns it to the passed (
r
,
g
,
b
) parameters.
The range of the assigned
r
,
g
and
b
parameters is
0
to
255
, where (
255
,
255
,
255
) is white, regardless of the bit depth of the image.
-
参数
-
[in]
|
x
|
The X coordinate.
|
[in]
|
y
|
The Y coordinate.
|
[out]
|
r
|
Assigned the red component.
|
[out]
|
g
|
Assigned the green component.
|
[out]
|
b
|
Assigned the blue component.
|
◆
GetPixelDirect()
Gets the color at [
x
,
y
].
The range of the assigned parameters are
0.0
to
255.0
, regardless of the bit depth of the image, where (
255.0
,
255.0
,
255.0
) is white. The range returns Float value, so 8, 16 and 32 bit precision is supported.
-
参数
-
[in]
|
x
|
The X coordinate.
|
[in]
|
y
|
The Y coordinate.
|
-
返回
-
Color as form of a 3D Vector.
◆
SetPixel()
Sets the pixel at [
x
,
y
] to the color specified by (
r
,
g
,
b
) (0 <= r/g/b <= 255).
The range of the
r
,
g
and
b
parameters is
0
to
255
, where (
255
,
255
,
255
) is white, regardless of the bit depth of the image.
-
参数
-
[in]
|
x
|
The X coordinate.
|
[in]
|
y
|
The Y coordinate.
|
[in]
|
r
|
The red component.
|
[in]
|
g
|
The green component.
|
[in]
|
b
|
The blue component.
|
-
返回
-
true
if the pixel was successfully set, otherwise
false
.
◆
GetAlphaPixel()
Gets the alpha value at [
x
,
y
] and assigns it to the passed parameter
val
(
0
<=
val
<=
255
).
-
参数
-
[in]
|
channel
|
The alpha channel to use.
|
[in]
|
x
|
The X coordinate.
|
[in]
|
y
|
The Y coordinate.
|
[out]
|
val
|
Assigned the alpha value.
|
◆
SetAlphaPixel()
Sets the alpha value at [
x
,
y
] to
val
.
-
参数
-
[in]
|
channel
|
The alpha channel to use.
|
[in]
|
x
|
The X coordinate.
|
[in]
|
y
|
The Y coordinate.
|
[in]
|
val
|
The alpha value.
0
<=
val
<=
255
|
◆
GetPixelCnt()
Reads
cnt
pixels from [
x
,
y
] in the bitmap to the
buffer
with the color mode
dstmode
, incrementing
inc
bytes for each pixel.
-
参数
-
[in]
|
x
|
The X coordinate of the first pixel to get.
|
[in]
|
y
|
The Y coordinate of the first pixel to get.
|
[in]
|
cnt
|
The number of pixels to get.
|
[out]
|
buffer
|
A pointer to a large enough memory buffer where the pixel data will be written. The caller owns the pointed buffer.
|
[in]
|
inc
|
The byte increment per pixel in the buffer.
|
[in]
|
dstmode
|
The destination color mode:
COLORMODE
|
[in]
|
flags
|
The flags:
PIXELCNT
|
[in]
|
conversion
|
This should be normally set to
nullptr
. Pass a color profile only if a conversion is wanted before retrieving the pixel data.
This only works if either the bitmap is
32
-bit per component (so no
8
/
16
-bit images) or the
dstmode
is
32
-bit per component.
The conversion is done before color reduction (e.g. if
dstmode
is
16
-bit the profile is first applied and then the data resampled to
16
-bit).
|
◆
SetPixelCnt()
Sets
cnt
pixels at [
x
,
y
] in the bitmap from
buffer
with color mode
srcmode
, incrementing
inc
bytes for each pixel.
-
参数
-
[in]
|
x
|
The X coordinate of the first pixel to set.
|
[in]
|
y
|
The Y coordinate of the first pixel to set.
|
[in]
|
cnt
|
The number of pixels to set.
|
[in]
|
buffer
|
A pointer to a large enough memory buffer containing the pixels to set. The caller owns the pointed buffer.
|
[in]
|
inc
|
The byte increment per pixel in the buffer.
|
[in]
|
srcmode
|
The source color mode:
COLORMODE
|
-
警告
-
None of the alpha modes are supported.
-
参数
-
-
返回
-
true
if successful, otherwise
false
.
◆
AddChannel()
Adds a new alpha channel to the bitmap.
-
注意
-
The bitmap class only supports up to
4
channels.
-
参数
-
[in]
|
internal
|
Should only be
true
for the first alpha. The internal alpha will be stored within a bitmaps if its format supports alphas.
|
[in]
|
straight
|
Should be
true
if the bitmap has to be interpreted as straight.
For information about straight alphas please take a look at the corresponding option in the render settings and the manual of
Cinema 4D
.
|
-
返回
-
The newly added channel if successful, otherwise
nullptr
.
◆
RemoveChannel()
Removes the specified
channel
from the bitmap.
-
参数
-
[in]
|
channel
|
The alpha channel to remove.
|
◆
GetInternalChannel()
[1/2]
const
BaseBitmap
* GetInternalChannel
|
(
|
void
|
|
)
|
const
|
Gets the internal read-only alpha channel.
-
注意
-
The internal alpha channel is the one that is saved together with the picture, with those formats that support this.
-
返回
-
The read-only internal alpha channel, or
nullptr
if no internal alpha is available. The bitmap owns the pointed channel.
◆
GetInternalChannel()
[2/2]
Gets the internal alpha channel.
-
注意
-
The internal alpha channel is the one that is saved together with the picture, with those formats that support this.
-
返回
-
The read-only internal alpha channel, or
nullptr
if no internal alpha is available. The bitmap owns the pointed channel.
◆
GetChannelCount()
Int32
GetChannelCount
|
(
|
void
|
|
)
|
const
|
Gets the number of alpha channels in the bitmap, including the internal channel.
-
返回
-
The number of alpha channels.
◆
GetChannelNum()
[1/2]
Gets the read-only alpha channel specified by
num
.
-
参数
-
-
返回
-
The requested read-only channel.
◆
GetChannelNum()
[2/2]
Gets the alpha channel specified by
num
.
-
参数
-
-
返回
-
The requested channel.
◆
GetData()
Gets bitmap data.
Private
.
-
参数
-
[in]
|
id
|
The data ID to Get:
BASEBITMAP_DATA
|
[in]
|
t_default
|
The default data to use.
|
-
返回
-
The retrieved data.
◆
SetData()
Sets bitmap data.
Private
.
-
参数
-
-
返回
-
true
if the data could be set, otherwise
false
.
◆
GetDirty()
Gets the incremented dirty count when the bitmap changes.
Private
.
-
返回
-
The dirty count.
◆
SetDirty()
Makes the bitmap dirty.
Private
.
◆
GetUpdateRegionBitmap()
[1/2]
const
BaseBitmap
* GetUpdateRegionBitmap
|
(
|
|
)
|
const
|
Gets the updated region of a bitmap (read-only).
-
返回
-
The updated region.
◆
GetUpdateRegionBitmap()
[2/2]
Gets the updated region of a bitmap.
-
返回
-
The updated region.
◆
GetUpdateRegion()
Gets the update region for the bitmap and resets it if requested.
-
参数
-
[out]
|
xMin
|
Left side of the update region.
|
[out]
|
xMax
|
Right side of the update region.
|
[out]
|
yMin
|
Top side of the update region.
|
[out]
|
yMax
|
Bottom side of the update region.
|
[in]
|
reset
|
True, if the update region should be reset.
|
◆
SetColorProfile()
Sets the color profile for the bitmap.
-
参数
-
[in]
|
profile
|
The new color profile. The caller owns the pointed color profile.
|
-
返回
-
true
if the color profile was successfully set, otherwise
false
.
◆
GetColorProfile()
Gets the color profile of the bitmap.
-
返回
-
The color profile of the bitmap, or
nullptr
if not available.
◆
GetMemoryInfo()
Int
GetMemoryInfo
|
(
|
void
|
|
)
|
const
|
Gets the size of the memory used by the bitmap.
-
返回
-
The memory size of the bitmap.
◆
IsMultipassBitmap()
Bool
IsMultipassBitmap
|
(
|
void
|
|
)
|
const
|
Checks if this
BaseBitmap
instance is a
MultipassBitmap
.
-
返回
-
true
if the instance can be safely cast to
MultipassBitmap
, otherwise
false
.
◆
SetCMAP()
If the image in the bitmap has
8
-bit indexed color, this function can be used to set the palette entries.
-
注意
-
All four parameters must be between
0
and
255
.
-
参数
-
[in]
|
i
|
The index.
0
<=
i
<=
255
|
[in]
|
r
|
The red component.
0
<=
r
<=
255
|
[in]
|
g
|
The green component.
0
<=
g
<=
255
|
[in]
|
b
|
The blue component.
0
<=
b
<=
255
|
◆
GetImageRef()
Bool
GetImageRef
|
(
|
SAVEBIT
|
saveBit
,
|
|
|
Bool
|
alpha
,
|
|
|
maxon::ImageRef &
|
imageRef
|
|
)
|
|
const
|
Gets the ImageRef for a
BaseBitmap
. The reference is stored internally. For the same saveBit / alpha pair you will get the same reference.
-
参数
-
[in]
|
saveBit
|
A combination of the following flags:
SAVEBIT
|
[in]
|
alpha
|
True, if you need the alpha image, false otherwise.
|
[out]
|
imageRef
|
A reference that gets the imageRef assigned.
|
-
返回
-
true
if the function succeeded, otherwise
false
.