SOL9 Sample: ImagesBlender

SOL9 2.0 Samples

1 Screenshot


2 Source code

/*
 * ImagesBlender.cpp 
 * Copyright (c) 2015 Antillia.com TOSHIYUKI ARAI. ALL RIGHTS RESERVED. 
 */


// 2012/04/20
// 2012/05/25

/*
This is a sample program based on Windows Gdiplus and SOL::ImageBlender classes.
 */

#include <sol/ColorTable.h>
#include <sol\gdiplus\GdiplusInitializer.h>
#include <sol\gdiplus\ImageBlender.h>

void _tmain(int argc, TCHAR* argv[])
{
  GdiplusInitializer initializer;
  
  ColorTable colorTable;

  if (argc != 7) {
    _tprintf(_T("ImageBlending: %s imageFileName alpha:scale backImageFileName alpha:scale backColor saveFileName\n"), argv[0]);
    _tprintf(_T("backColor takes a RGB color format: #RRGGBB \n"));

    return;
  }

  try {
    
    File file;
    if (file.isExistent(argv[1]) == FALSE) {
      throw Exception(0, _T("File not found :'%s'"), argv[1]);
    }

    if (file.isExistent(argv[3]) == FALSE) {
      throw Exception(0, _T("File not found :'%s'"), argv[3]);
    }

    ImageBlender blender;
    
    //Image Alpha-blending 
    if (argc == 7) {
      LinkedList imageFileList;
      //2015/07/15
      //imageFileList.addLast(new ImageFileFilter(argv[3], argv[4], 100));
      //imageFileList.addLast(new ImageFileFilter(argv[1], argv[2], 100));
      imageFileList.addLast(new ImageFileFilter(argv[3], argv[4], "100%", "center"));
      imageFileList.addLast(new ImageFileFilter(argv[1], argv[2], "100%", "center"));
      
      const TCHAR* backColor = argv[5];

      const TCHAR* saveFileName = argv[6];
      
      bool rc = blender.blend(backColor, imageFileList, saveFileName);
      if (rc) {
        _tprintf(_T("OK. Alpha-blended '%s' with '%s' and saved to '%s'\n"),
          argv[1], argv[3], saveFileName);
      } else {
        _tprintf(_T("Failed to alpha-blend '%s' with '%s' and save to '%s'\n"),
          argv[1], argv[3], saveFileName);
      }
    }
  } catch (Exception& ex) {
    ex.printf();
  }
}

Last modified: 2 May 2016

Copyright (c) 2016 Antillia.com ALL RIGHTS RESERVED.