From The Foundry MODO SDK wiki
Revision as of 16:11, 31 January 2016 by Ivo.grigull (Talk | contribs) (Created page with "{{Snippet |summary=This example command goes through all image layers (as found in exr or psd files) and reads the first pixel |code=<syntaxhighlight lang="cpp">/* Python e...")

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search


This example command goes through all image layers (as found in exr or psd files) and reads the first pixel


Python equivalent:
import modo
lx.eval ('clip.addStill /home/ivo/modo/sdk/projects/CMakeLinuxTest/image/multipage_tiff_example.psd true')
im = modo.Scene().selected[2]
ch = im.channel('imageStack').get()
ift = lx.object.ImageFilter(ch)
image = ift.Generate(64,64, None)
storage = lx.object.storage('b', 4)
image.GetPixel( 0,0, lx.symbol.iIMV_RGBA, storage)
print [storage[i] for i in xrange(4)]
#include <lxidef.h>
#include <lx_item.hpp>
#include <lx_plugin.hpp>
#include <lx_log.hpp>
#include <lx_image.hpp>
#include <lxu_command.hpp>
#include <vector>
#include <string>
static char *SERVER_NAME             = "imagetest";
static char *SERVER_USERNAME         = "Image Test";
static char *LOG_NAME                = "imagetest";
class CCmdImage : public CLxBasicCommand
	static LXtTagInfoDesc           descInfo[];
	int basic_CmdFlags() LXx_OVERRIDE {
		return LXfCMD_UNDO;
	void cmd_Execute(unsigned int flags) LXx_OVERRIDE {
		CLxLoc_SceneService svc;
		CLxSceneSelection sceneSelection;
		CLxUser_Scene scene;
		CLxUser_Item item;
		LXtItemType imgLayerType;
		uint count, t;
		svc.ItemTypeLookup(LXsITYPE_IMAGELAYER, &imgLayerType);
		scene.ItemCount(imgLayerType, &count);
		for(t=0; t< count; t++)
			scene.GetItem (imgLayerType,t,item);
			if(item.IsA (imgLayerType))
				CLxUser_ChannelRead read;
				read.from (item, 0.0);
				CLxUser_ImageFilter filter;
				read.Object (item, LXsICHAN_VIDEOCLIP_IMAGESTACK, filter);
				bool test = filter.test();
				CLxUser_Image layimg;
				filter.Generate (64, 64, 0, layimg);
				test = layimg.test();
				LXtPixelFormat format = layimg.Format();
				if (format == LXiIMV_RGBA)
					unsigned char pixel[4];
					LxResult result = layimg.GetPixel (0, 0, format, pixel);
LXtTagInfoDesc CCmdImage::descInfo[] = {
void initialize()
	CLxGenericPolymorph *srv = new CLxPolymorph<CCmdImage>;
	srv->AddInterface(new CLxIfc_Command    <CCmdImage>);
	srv->AddInterface(new CLxIfc_StaticDesc <CCmdImage>);
	lx::AddServer(SERVER_NAME, srv);