ImageLoader.cpp
branchv_0
changeset 1 fb65455622b9
parent 0 bb715a82a8f1
child 13 82bb4fe2fd4a
equal deleted inserted replaced
0:bb715a82a8f1 1:fb65455622b9
       
     1 /**
       
     2  * ShaderShark
       
     3  * Copyright © 2023 František Kučera (Frantovo.cz, GlobalCode.info)
       
     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, version 3 of the License.
       
     8  *
       
     9  * This program is distributed in the hope that it will be useful,
       
    10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
       
    11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
       
    12  * GNU General Public License for more details.
       
    13  *
       
    14  * You should have received a copy of the GNU General Public License
       
    15  * along with this program. If not, see <http://www.gnu.org/licenses/>.
       
    16  */
       
    17 
       
    18 #include <iostream>
       
    19 
       
    20 #include <Magick++.h>
       
    21 
       
    22 #include "ImageLoader.h"
       
    23 #include "AllocatedBuffer.h"
       
    24 
       
    25 ImageLoader::ImageBuffer* ImageLoader::loadImage(const Buffer& input) {
       
    26 	Magick::Blob inputBlob(input.getData(), input.getSize());
       
    27 	Magick::Image image(inputBlob);
       
    28 
       
    29 	// Magick::PixelPacket* parsedPixels = parsedImage.getPixels(
       
    30 	//     0, 0, parsedImage.size().width(), parsedImage.size().height());
       
    31 	
       
    32 	Magick::Blob outputBlob;
       
    33 	image.magick("RGBA");
       
    34 	image.write(&outputBlob);
       
    35 
       
    36 	ImageBuffer* outputBuffer = new ImageBuffer(
       
    37 			(void*) outputBlob.data(),
       
    38 			outputBlob.length(),
       
    39 			image.size().width(),
       
    40 			image.size().height());
       
    41 
       
    42 	return outputBuffer;
       
    43 }