<html><head><base href="x-msg://8423/"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Hi Jerome,<div><br></div><div>The best way of doing this is to set the colours on the Channels themselves, then reset the default rendering settings.</div><div>This means that whenever any user resets their rendering settings on the image, they will default to the 'correct' colours. </div><div><br></div><div>Here's some (pseudo code) of what I'm doing in Python - Hopefully you can work out the C++</div><div>Not sure if you'll have to reload as I'm doing. Try it and see.</div><div><br></div><div>You can get channels via pixels,</div><div>EITHER via the rendering engine (once you've set Ids etc)...</div><div><br></div><div>pixels = re.getPixels()</div><div><br></div><div><br></div><div>OR via the query service...</div><div><br></div><div><div>pid = image.getPrimaryPixels().getId().getValue()</div><div>params = omero.sys.Parameters()</div><div>params.map = {"pid": rlong(pid)}</div><div>query = "select p from Pixels p join fetch p.channels as c join fetch c.logicalChannel as lc where p.id=:pid"</div><div>pixels = session.getQueryService().findByQuery(query, params)</div></div><div><br></div><div>for c in pixels.iterateChannels():</div><div><span class="Apple-tab-span" style="white-space:pre">        # </span>??? <span class="Apple-tab-span" style="white-space:pre">need to reload channels to avoid optimistic lock on update</span> ??? <span class="Apple-tab-span" style="white-space:pre">
</span>c<span class="Apple-tab-span" style="white-space:pre"> = conn.getQueryService().get("Channel", c.id</span>.val<span class="Apple-tab-span" style="white-space:pre">)        </span># could try to skip this step</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>c.red = omero.rtypes.rint(r)</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>c.green = omero.rtypes.rint(g)</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>c.blue = omero.rtypes.rint(b)</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>c.alpha = omero.rtypes.rint(255)</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>session.getUpdateService().saveObject(c)</div><div><br></div><div><br></div><div>Than reset </div><div>session.getDeleteService().deleteSettings(imageId)</div><div><br></div><div><div>If this doesn't work, maybe also try:</div><div>renderingEngine.resetDefaults()</div></div><div><br></div><div><br></div><div> Let us know how you get on,</div><div><br></div><div><br></div><div> Will</div><div><br></div><div><br></div><div><br></div><div><div><div>On 22 Mar 2012, at 12:11, Jerome Avondo wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div class="hmmessage" style="font-size: 10pt; font-family: Tahoma; "><div dir="ltr">Hi,<div><br></div><div>I am trying to set the rendering colours for an image I upload to the server via the C++ API...</div><div>The image upload is all good, but I am a little confused with setting the rendering options...</div><div><span style="font-size: 10pt; ">I am uploading a 3 channel image, and I set the render settings as follows:</span></div><div><br></div><div><span class="Apple-tab-span" style="font-size: 10pt; white-space: pre; ">        </span><span style="font-size: 10pt; ">for(int c=0; c<csize; c++)</span></div><div><div><span class="Apple-tab-span" style="white-space: pre; ">        </span>{</div><div><span class="Apple-tab-span" style="white-space: pre; ">                </span>if(c==0)</div><div><span class="Apple-tab-span" style="white-space: pre; ">                </span>{</div><div><span class="Apple-tab-span" style="white-space: pre; ">                        </span>renderingEngine->setChannelWindow(c, float(0), float(255));</div><div><span class="Apple-tab-span" style="white-space: pre; ">                        </span>renderingEngine->setRGBA(c, 255, 0, 0, 255);</div><div><span class="Apple-tab-span" style="font-size: 10pt; white-space: pre; ">                </span><span style="font-size: 10pt; ">}</span></div><div><span class="Apple-tab-span" style="white-space: pre; ">                </span>if(c==1)</div><div><span class="Apple-tab-span" style="white-space: pre; ">                </span>{</div><div><span class="Apple-tab-span" style="white-space: pre; ">                        </span>renderingEngine->setChannelWindow(c, float(0), float(255));</div><div><span class="Apple-tab-span" style="white-space: pre; ">                        </span>renderingEngine->setRGBA(c, 0, 255, 0, 255);</div><div><span class="Apple-tab-span" style="font-size: 10pt; white-space: pre; ">                </span><span style="font-size: 10pt; ">}</span></div><div><span class="Apple-tab-span" style="white-space: pre; ">                </span>if(c==2)</div><div><span class="Apple-tab-span" style="white-space: pre; ">                </span>{</div><div><span class="Apple-tab-span" style="white-space: pre; ">                        </span>renderingEngine->setChannelWindow(c, float(0), float(255));</div><div><span class="Apple-tab-span" style="white-space: pre; ">                        </span>renderingEngine->setRGBA(c, 0, 0, 255, 255);</div><div><span class="Apple-tab-span" style="font-size: 10pt; white-space: pre; ">                </span><span style="font-size: 10pt; ">}</span></div><div><span class="Apple-tab-span" style="font-size: 10pt; white-space: pre; ">        </span><span style="font-size: 10pt; ">}</span></div></div><div><span style="font-size: 10pt; "><br></span></div><div><div><span class="Apple-tab-span" style="white-space: pre; ">        </span>renderingEngine->saveCurrentSettings();</div><br class="Apple-interchange-newline"></div><div>Basically I want my 3 channel image to be red, green, blue....</div><div>However the first two channels appear as white, whilst only the last is blue... I tried moving the <span style="font-size: 10pt; ">saveCurrentSettings() after each channel call, but no joy.</span></div><div><span style="font-size: 10pt; ">I'm sure it's something simple, but can't figure it out... </span></div><div>Thanks in advance,</div><div><br></div><div><span style="font-size: 10pt; ">Jerome.</span></div></div>_______________________________________________<br>ome-devel mailing list<br><a href="mailto:ome-devel@lists.openmicroscopy.org.uk">ome-devel@lists.openmicroscopy.org.uk</a><br><a href="http://lists.openmicroscopy.org.uk/mailman/listinfo/ome-devel">http://lists.openmicroscopy.org.uk/mailman/listinfo/ome-devel</a><br></div></blockquote></div><br></div></body></html>