How to use renderGridToBuffer

46 views
Skip to first unread message

mederich...@gmail.com

unread,
Dec 22, 2011, 6:06:45 AM12/22/11
to indigo-general
Hi everybody.

I currently use Indigo version 1.1 beta6 pre10 for Java.
I encountered a problem with the method
renderGridToBuffer(indigoMolList, null, 4);
indigoMolList is a indigoArray with 4 molecules (IndigoObject).

I have set this parameters for indigo option:
session.setOption("render-output-format", "png");
session.setOption("render-coloring", "true");
session.setOption("render-bond-length", "40");
session.setOption("render-background-color", 1.f, 1.f, 1.f);
session.setOption("render-margins", 10, 10);

The problem is when I use this method I retrieve a
"java.lang.NullPointerException".

By the way, when I use the method renderGridToFile(indigoMolList,
null, 4, filePath) I have no problems, it works prefectly.
So if you are an explanation....

Best regards.

médérich

Mikhail Kozhevnikov

unread,
Dec 23, 2011, 7:30:52 PM12/23/11
to indigo-...@googlegroups.com, mederich...@gmail.com
Hi Médérich,

It turns out there's a bug in our Java API here, we'll provide a fix shortly. Otherwise things should work just fine this way. Thank you for the info! 

Cheers, 
Mikhail

Mikhail Rybalkin

unread,
Dec 27, 2011, 4:13:26 PM12/27/11
to indigo-general
Hi Médérich,

We have released Indigo 1.1-beta6 with this bug fixed.

Best regards.
Mikhail Rybalkin

On 24 дек, 04:30, Mikhail Kozhevnikov <kozhevni...@ggasoftware.com>
wrote:
> Hi Médérich,
>
> It turns out there's a bug in our Java API here, we'll provide a fix
> shortly. Otherwise things should work just fine this way. Thank you for the
> info!
>
> Cheers,
> Mikhail
>
> On Thu, Dec 22, 2011 at 12:06 PM, mederich.besn...@gmail.com <

mederich...@gmail.com

unread,
Dec 28, 2011, 8:57:15 AM12/28/11
to indigo-general
Thank you.

mederich...@gmail.com

unread,
Dec 28, 2011, 9:49:39 AM12/28/11
to indigo-general
I have test our last version (1.1-beta6) and I always have rendering
problems with renderGridToBuffer and renderGridToFile.

For renderGridToBuffer:
I think it's a thread problem because when I run my program in debug
mode (slower execution time) it works.

For renderGridToFile:
I don't know why but I have large blank between molecules and grid-
title-property. Moreover, when I use renderGridToBuffer I have some
empty PNG file.


I hope this can help you.

On 28 déc, 14:57, "mederich.besn...@gmail.com"

Mikhail Rybalkin

unread,
Dec 28, 2011, 9:55:57 AM12/28/11
to indigo-general
Are you using the same Indigo instance for multithreaded rendering?
Currently we have a limitation, that one Indigo instance with all its
objects can be used only is a one thread in a one moment. If you wants
to render objects in a mutlthreaded way, you have to create multiple
instance of Indigo, or add a synchronized section for rendering to
avoid multithreading conflicts. This is because renderGridToBuffer
uses internal buffer and this buffer belongs to Indigo instance.

On Dec 28, 6:49 pm, "mederich.besn...@gmail.com"

mederich...@gmail.com

unread,
Dec 28, 2011, 11:04:31 AM12/28/11
to indigo-general
I don't use multithread rendering.
I create an instance of indigoRenderer (to save as gridFile or
gridBuffer) for each IndigoObjectArray.

I don't know why but IndigoRenderer randomly works.

Best regards.

Mikhail Rybalkin

unread,
Dec 28, 2011, 4:07:47 PM12/28/11
to indigo-general
Could you provide us some test code, or pseudocode that will show the
issue, or even give us more details. From you explanation I didn't
understand how to reproduce it. It will help us to localize the bug
faster, and provide you a fixed version.

On Dec 28, 8:04 pm, "mederich.besn...@gmail.com"

mederich...@gmail.com

unread,
Dec 29, 2011, 3:53:44 AM12/29/11
to indigo-general
For example I use this code in a method to create an ImageIcon
corresponding to IndigoObjectArray. That is to say I have a new
instance of Indigo and IndigoRenderer for each IndigoObjectArray:

// Set Indigo and IndigoRenderer instance
Indigo session = new Indigo();
IndigoRenderer renderer = new IndigoRenderer(session);

// Set Indigo Option for rendering
session.setOption("render-output-format", "png");
session.setOption("render-coloring", "true");
session.setOption("render-bond-length", "40");
session.setOption("render-background-color", 1.f, 1.f, 1.f);
session.setOption("render-margins", 10, 10);
session.setOption("render-grid-title-property","NAME" );

// Create an IndigoObjectArray
IndigoObject indigoMolList = session.createArray();
for (IndigoObject indigoMol : session.iterateSDFile("C\\MyFile.sdf")){
item.setProperty("NAME", item.name());
item.layout();
indigoMolList.arrayAdd(item);
}

// Its here I have "JavaPointerNullException" randomly....
byte[] byteList = renderer.renderGridToBuffer(indigoMolList, null, 2);

// Set ImageIcon
ImageIcon imageIcon = new ImageIcon(byteList);


Best regards,
Médérich.

Mikhail Rybalkin

unread,
Dec 30, 2011, 1:01:40 AM12/30/11
to indigo-general
Thank you for this code. We have reproduced this issue and fixed it.
You can try Indigo 1.1-beta7 version.

On Dec 29, 12:53 pm, "mederich.besn...@gmail.com"
Reply all
Reply to author
Forward
0 new messages