1 /**
2  * MltImage.cpp - MLT Wrapper
3  * Copyright (C) 2021 Meltytech, LLC
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library 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 GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
18  */
19 
20 #include "MltImage.h"
21 
22 using namespace Mlt;
23 
Image()24 Image::Image( )
25 {
26 	instance = mlt_image_new();
27 }
28 
Image(mlt_image image)29 Image::Image( mlt_image image )
30  : instance( image )
31 {
32 }
33 
Image(int width,int height,mlt_image_format format)34 Image::Image( int width, int height, mlt_image_format format )
35 {
36 	instance = mlt_image_new();
37 	alloc( width, height, format );
38 }
39 
~Image()40 Image::~Image( )
41 {
42 	mlt_image_close( instance );
43 }
44 
format()45 mlt_image_format Image::format()
46 {
47 	return instance->format;
48 }
49 
width()50 int Image::width()
51 {
52 	return instance->width;
53 }
54 
height()55 int Image::height()
56 {
57 	return instance->height;
58 }
59 
set_colorspace(int colorspace)60 void Image::set_colorspace( int colorspace )
61 {
62 	instance->colorspace = colorspace;
63 }
64 
colorspace()65 int Image::colorspace()
66 {
67 	return instance->colorspace;
68 }
69 
alloc(int width,int height,mlt_image_format format,bool alpha)70 void Image::alloc( int width, int height, mlt_image_format format, bool alpha )
71 {
72 	instance->width = width;
73 	instance->height = height;
74 	instance->format = format;
75 	mlt_image_alloc_data( instance );
76 	if ( alpha )
77 		mlt_image_alloc_alpha( instance );
78 }
79 
init_alpha()80 void Image::init_alpha()
81 {
82 	mlt_image_alloc_alpha( instance );
83 }
84 
plane(int plane)85 uint8_t* Image::plane( int plane )
86 {
87 	return instance->planes[plane];
88 }
89 
stride(int plane)90 int Image::stride( int plane )
91 {
92 	return instance->strides[plane];
93 }
94