text/plain ColorSaver.txt — 1.6 KB

File contents

// ColorSaver
// This macro will allow the values registered by the color picker to be written to a text window
// This tool displays the coordinates and RGB values of pixels
// Eric Nord 2/10/09

    macro "ColorSaver Tool -C42f-o4499" {
    requires("1.38m");    
	//initialize vairables	
	title1 = "RGB values";
 	title2 = "["+title1+"]";
  	f = title2;
  	if (!isOpen(title1)) { //if not open text window "RGB values"
     if (getVersion>="1.41g") //create text window
        run("Text Window...", "name="+title2+" width=50 height=6");
     else
        run("New... ", "name="+title2+" type=[Text File] width=50 height=6");
	// print this text on first 2 lines 	
	print(f,"This macro stores the x,y, and RGB color values for the selected pixel(s).\n");
	print(f,"You can add notes, etc by typing in the text window.\n");
 	print(f,"x\t y\t r\t g\t b \n");
	}   
	getCursorLoc(x, y, z, flags);
        v = getPixel(x,y);
        if (bitDepth==24) {
            red = (v>>16)&0xff;  // extract red byte (bits 23-17)
            green = (v>>8)&0xff; // extract green byte (bits 15-8)
            blue = v&0xff;       // extract blue byte (bits 7-0)
            if (nSlices>1)
                print(f,"+x+", "+y+", "+z+", "+red+", "+green+", "+blue+\n");
            else
		print(f,x+"\t"+y+z+"\t"+red+"\t"+green+"\t"+blue+"\n");                 
		//print(f,"+x+", "+y+", "+red+", "+green+", "+blue+");
     } else
            if (nSlices>1)
                print(f,"+x+", "+y+", z="+z+", value="+v+\n");
            else
                print(f,"+x+", "+y+", value="+v+\n");
   }

Spotlight