Dirk Reiners wrote:
Hi Marcus,

On Thu, 2006-04-20 at 13:45 +0200, Marcus Lindblom wrote:
Marcus Lindblom wrote:
[snip]
Here is my code. Is there anything obvious you can spot?

nothing obvious. Are the subimages ok, and only the final image wrong?

Most, but not all subimages were wrong. If I take a 800x600 screenshot with a 640x480 window, all but the 160x480 subpart are wrong. (the 120-pixel high ones seem to have use the entire view and the 640x480 one is just in a single color (seem to strech one pixel). Also, the final image was completely blank.

However, I got it to work! There were two issues:

GrabForeground::setAutoResize() did not work as I expected (I was just mostly just guessing how it would work). So by setting that to false and resizing myself I got proper screenshots.

Also, Image::setSubData() required me to set srcDepth to 1, otherwise, no data. This is due to the line:

  UInt32 zMax = osgMin(getDepth(),  offZ + srcD);

which obviously is zero if offZ and srcD are zero, so it won't loop very far at all. Duh! :)

The one thing that worries me a little is running the safe in a separate
thread, have you tried it without that?

I have now. It made no difference, so I'll keep it in the thread, since it takes more than a few seconds to save a big screenshot as png. :)

Regards,
/Marcus
---
So the diff that made it work:
@@ -84,7 +84,7 @@
         CPEditAll(grabber);
         grabber->setImage(img);
         grabber->setActive(true);
-        grabber->setAutoResize(true);
+        grabber->setAutoResize(false);
     }

     std::vector<TileCameraDecoratorRefPtr> decorators;
@@ -123,11 +123,12 @@

                 TileCameraDecoratorPtr camdec = decorators[i];
                 CPEditAll(camdec);
                 camdec->setSize(xPos / float(m_size.x()),
                                 yPos / float(m_size.y()),
                                 (xPos + xSize) / float(m_size.x()),
                                 (yPos + ySize) / float(m_size.y()));

+                img->set(output->getPixelFormat(), xSize, ySize);
             }

             s_log.info("Grabbing image at %i,%i of size %i,%i", xPos,
@@ -135,13 +136,13 @@
             m_window->render();

             CPEditAll(output);
-            output->setSubData(xPos, yPos, 0, xSize, ySize, 0,
+            output->setSubData(xPos, yPos, 0, xSize, ySize, 1,
                                grabber->getImage()->getData());

         }
     }



-------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Opensg-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensg-users

Reply via email to