Hi Wayne,
Hello all, I need to temporarily change the background color and then restore it. Below is a rather awkward macro to do this. I need to create a dummy RGB image, because otherwise getValue("color.background") returns either a 24-bit color or an 8-bit index, depending on the type of the front window. It also would be nice if colors could be set with either one 24-bit or three 8-bit arguments. My question: is the getValue("color.background") behavior intended as it is, and is there an easier way to save and restore the background color? //save background color --- newImage("dummy", "RGB White", 200, 20, 1); backColor = getValue("color.background"); close; //restore background color --- r = backColor&0x0ff0000>>16; g = backColor&0x0ff00>>8; b = backColor&0x0ff; setBackgroundColor(r, g, b) Norbert Vischer -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
> I need to temporarily change the background color and then restore it.
> Below is a rather awkward macro to do this. I need to create a dummy RGB image, > because otherwise getValue("color.background") returns either > a 24-bit color or an 8-bit index, depending on the type of the front window. > It also would be nice if colors could be set with either one 24-bit or three 8-bit arguments. > > My question: is the getValue("color.background") behavior intended as it is, and is there > an easier way to save and restore the background color? > > > //save background color --- > newImage("dummy", "RGB White", 200, 20, 1); > backColor = getValue("color.background"); > close; > > > //restore background color --- > r = backColor&0x0ff0000>>16; > g = backColor&0x0ff00>>8; > b = backColor&0x0ff; > setBackgroundColor(r, g, b) > > > > Norbert Vischer > Meanwhile, I found saveSettings() and restoreSettings() which makes things simpler, but I also need to know the value of the background color, so I still need the dummy window. Norbert Vischer -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
On Dec 2, 2012, at 9:21 AM, Norbert Vischer wrote:
>> I need to temporarily change the background color and then restore it. >> Below is a rather awkward macro to do this. I need to create a dummy RGB image, >> because otherwise getValue("color.background") returns either >> a 24-bit color or an 8-bit index, depending on the type of the front window. >> It also would be nice if colors could be set with either one 24-bit or three 8-bit arguments. >> >> My question: is the getValue("color.background") behavior intended as it is, and is there >> an easier way to save and restore the background color? >> >> //save background color --- >> newImage("dummy", "RGB White", 200, 20, 1); >> backColor = getValue("color.background"); >> close; >> >> //restore background color --- >> r = backColor&0x0ff0000>>16; >> g = backColor&0x0ff00>>8; >> b = backColor&0x0ff; >> setBackgroundColor(r, g, b) >> >> Norbert Vischer > > Meanwhile, I found saveSettings() and restoreSettings() which makes things simpler, but I also need to know the value of the background color, so I still need the dummy window. The getValue("rgb.background") macro function, available in v1.47g or later, returns the value of the background color. ImageJ 1.47g also adds setForegroundColor(value) and setBackgroundColor(value) functions. -wayne -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Free forum by Nabble | Edit this page |