raster image don't display!
raster image don't display!
hi,all
please help me ,i use loadrasterimage(odstring filename) in my ocx,but in my ocx application don't display,in autocad 2004 is fine,why? is any module not load?
please look the attachments file.
raster image clipping
hi,
i test attached dwg with 2.6.1.
for images, which incorrectly displayed, enabled "show clipping" mode. clipping region is not correct, and autocad skips clipping of images in this case, but dd processes images clipping with this clipping boundary.
to resolve problem in the drawing, you can disable image clipping, delete invalid clipping boundary from image, or enter new (valid) clipping boundary.
hi,amark
to resolve problem in the drawing, you can disable image clipping, delete invalid clipping boundary from image, or enter new (valid) clipping boundary.[/quote]
are the images have questions, or my code have some bugs?
my code is :
code:
void cdwgviewerview::insertimage(cdwgviewerdoc* pdoc, cdwgviewerview* pview,cstring imagefile,odgepoint3d basepoint,oduint32 w,oduint32 h )
{
double scalefactor = 1.0;
double rotationangle = 0.0;
oduint32 nwidth, nheight;
odstring imagename;
// get image to add
imagename = odstring(imagefile);
// open model space for write getdocument()->m_pdb
oddbblocktablerecordptr precord = pdoc->m_pdb->getmodelspaceid().safeopenobject(oddb::kforwrite);
// ensure that this drawing has an image dictionary
oddbobjectid imagedictid = oddbrasterimagedef::createimagedictionary(precord->database());
// open the image dictionary.
oddbdictionaryptr pimagedict = imagedictid.safeopenobject(oddb::kforwrite);
// check the dictionary for specified image definition name
int ind1 = imagename.reversefind('\\');
int ind2 = imagename.reversefind('.');
odstring key;
if ( ind1 != -1 )
{
if ( ind2 != -1 )
key = imagename.mid(ind1+1, ind2 - ind1 - 1);
else
key = imagename.mid(ind1+1);
}
else
{
if ( ind2 != -1 )
key = imagename.mid(0, ind2);
else
key = imagename;
}
nwidth = 1;
nheight = 1;
// try to load image and detect it size
// messagebox(imagename.c_str());
odrxrasterservicesptr prassvcs =:

drxdynamiclinker()->loadapp(l"rxrasterservices");
odgirasterimageptr rast =prassvcs->loadrasterimage(imagename);
// if ( !rast.isnull() )
//
// odgevector2d rastsize= oddbrasterimagedef::size();
// rast.nheight=nheight;
// rast.nwidth=nwidth;
oddbobjectid imagedefid = pimagedict->getat(key);
if (imagedefid.isnull())
{
// an image definition was not find, so create new one
oddbrasterimagedefptr pimagedef = oddbrasterimagedef::createobject();
imagedefid = pimagedict->setat(key, pimagedef);
// set remaining imagedef attributes.
pimagedef->setsourcefilename(imagename);
// pimagedef->setimage(odgirasterimagedesc::createobject(w, h, odgirasterimage::kinch));
pimagedef->setimage(rast);
// check raster variables
oddbrastervariablesptr prvars = oddbrastervariables:

penrastervariables(precord->database(), oddb::kforwrite);
if (odgirasterimage::knone == prvars->userscale())
{
prvars->setuserscale(odgirasterimage::kmillimeter);
prvars->setimageframe(oddbrastervariables::kimageframeabove);
prvars->setimagequality(oddbrastervariables::kimagequalityhigh);
}
}
// add image entity, which references the above imagedef. an imagedef
// can be used by multiple image entities.
oddbrasterimageptr pdbraster = oddbrasterimage::createobject();
// add image entity to block.
precord->appendoddbentity(pdbraster);
// set remaining image attributes.
pdbraster->setimagedefid(imagedefid);
// odgevector3d nu(odgevector3d::kxaxis), nv(odgevector3d::kyaxis);
// nu.rotateby(rotationangle, odgevector3d::kzaxis);
// nu *= scalefactor;
//
// nv.y = nv.y * nheight / nwidth; // take into account aspect ratio
// nv.rotateby(rotationangle, odgevector3d::kzaxis);
// nv *= scalefactor;
odgevector2d imagesize= pdbraster->imagesize(false);
pdbraster->setorientation(basepoint, odgevector3d(w/25.4, 0, 0), odgevector3d(0.0, h/25.4, 0));
pdbraster->setdisplayopt(oddbrasterimage::kshow, true);
pdbraster->setdisplayopt(oddbrasterimage::kshowunaligned, true);
pdbraster->setbrightness(oduint8(50));
pdbraster->setcontrast(oduint8(50));
odgepoint2darray pts;
// as a second point we have to use image size
pts.push_back(odgepoint2d(0, 0));
pts.push_back(odgepoint2d(w/2, 0));
pts.push_back(odgepoint2d(w/2, h/2));
pts.push_back(odgepoint2d(0, h/2));
pts.push_back(odgepoint2d(0, 0));
pdbraster->setclipboundary(pts);
pdbraster->setdisplayopt(oddbrasterimage::kshow, true);
pdbraster->setdisplayopt(oddbrasterimage::kshowunaligned, true);
pdbraster->setdisplayopt(oddbrasterimage::kclip, true);
// // pdbraster->setclipped(true);
return;
}please help me!
raster image clipping
hi,
boundary region for image specified incorrectly.
to specify rectangular clipping boundary use two points, instead of five.
for example (default values for entire image in example drawing):
code:
odgepoint2darray pts;
// as a second point we have to use image size
pts.push_back(odgepoint2d(-0.5, -0.5));
pts.push_back(odgepoint2d(156.5, 131.5));
pdbraster->setclipboundary(pts);btw, in example drawing i see following values in boundary array:
{ 0, 0 },
{ 6, 0 },
{ 6, 1 },
{ 0, 1 },
{ 0, 0 }
, this values too small to display entire image.
hi,amark,
the b.dwg file in the mfcappdll.exe display is ok,why?
hi,amark
i think the question is not the clip boundary,the rect is small or large not effect the image display.
what version of dd you are use?
hi amark,
dd version is 2.6.1.
last edited by jum_xie; 6th august 2008 at 06:16 pmfff">.
raster image don't display
hi,
i test insertimage() function in 2.6.1. it is works correctly and i could not reproduce wrong behaviour.
please, answer on the following questions:
1) is rasterprocessor module loaded (it is needed for display/convert raster images)?
2) does other images displayed correctly in your application (in files saved by acad, for example)?
3) what vectorizer you are use? test rendering with other vectorizers if you can.
hi,amark,
1.rasterprocessor load or not,the question has exists
2.i replace the wingdi.gs with winopengl.gs,the question has exists
i think the question is the ocx framework and the mfcapp framework different,i insert the raster image in the dwg with the autocad 2004, use the ocx app open the dwg file,the image don't display,but in singledoc.exe(the sample in dd nonlibs) is ok.
the ocx app in the attachments, please put bbb.dwg in the d:\
please help me!
raster image don't display
hi, jum_xie,
i check attached ocx, and found following problem:
raster image has jpeg file format (c:\a.jpg), but application compiled without jpeg support.
see exgirasterimage.cpp:
code:
#ifdef raster_jpeg6b
#undef far
extern "c"
{
#include "jpeglib.h"
}so, to enable jpeg support you must:
- add raster_jpeg6b preprocessor definition to project.
- add include directory ".\dwgdirect\thirdparty\jpeg-6b" to vs options.
- link with dd_vc6md_jpeg.lib library.
hi,amark,
the problem has been resolved,but i want store the rasterimage in the dwg file,can you give me some advice?
where is no "standard" autocad's entity which stores raster data inside dwg file.
sergey slezkin