Message 1 of 2
What is the magnitude of with in AcGiGeometry::image

Not applicable
02-11-2014
04:30 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi,
I've now got an image displaying in my drawing, but it isn't scaleing correctly.
With this code I'm trying to display an image that is 50 units by 50 units.
Adesk::Boolean isPerspective = pVd->viewport().isPerspective(); AcGePoint3d originPos(0.0, 0.0, 0.0); AcGePoint2d scaleUnits; pVd->viewport().getNumPixelsInUnitSquare(originPos, scaleUnits, isPerspective != 0); long xWidth = (long)ceil(50 * scaleUnits.x); long yWidth = (long)ceil(50 * scaleUnits.y); if (xWidth > 2048 || yWidth > 2048) { if (xWidth >= yWidth) { yWidth = (long)(yWidth * (double)(2048.0 / xWidth)); xWidth = 2048; } else { xWidth = (long)(xWidth * (double)(2048.0 / yWidth)); yWidth = 2048; } } AcGiPixelBGRA32 *colorBlock = new AcGiPixelBGRA32[xWidth * yWidth]; for (int i = 0; i < yWidth; i++) { for (int j = 0; j < xWidth; j++) { colorBlock[(i*xWidth)+j].setRGBA(0,255,0,255); } } AcGiImageBGRA32 imageSource(xWidth, yWidth, colorBlock); double xScale = xWidth / scaleUnits.x; double yScale = yWidth / scaleUnits.y; AcGeVector3d u(xScale, 0.0, 0.0); AcGeVector3d v(0.0, yScale, 0.0); pVd->geometry().image(imageSource, originPos, u, v,AcGiGeometry::kTransparency8Bit);
When you zoom in close and redraw the image will shrink. Zoom out and the image displays correctly. When debugging the shrinking problem occurs when my xScale value is greater then scaleUnits.x value.
Another way to ask the question is; If I have a 2048x2048 image where each pixel is .0244 meters, what does the magnitude need to be so it will display at 50mx50m?
Thanks