Are there any libraries c++/.net/java/.. which can be used to convert various format as pdf, jpeg,bmp to autocad dwg and back.
Thanking in advance
Are there any libraries c++/.net/java/.. which can be used to convert various format as pdf, jpeg,bmp to autocad dwg and back.
Thanking in advance
Conversion from vector formats like DWG, to raster bitmaps like JPEG and BMP is called rasterization, and is relatively straightforward.
The reverse conversion from raster bitmaps to a vector format can be done in at least 2 ways:
The first approach is fairly simple, as long as the output vector format supports embedding bitmaps, which is the case with the 2 common AutoCAD formats DWG and DXF.
The second approach is called vectorization or image tracing, and it can be tricky to implement in a fully-automated manner.
The company I work for has an SDK that supports rasterization of DWG and other vector files. It also supports embedding raster bitmaps inside DXF and other vector formats (but it doesn’t support creating DWG files).
The C++ code to convert from DWG to JPEG looks like this:
BITMAPHANDLE bitmapFromVector = { 0 };
// specify rasterization size
L_2DSetViewport(2000, 1600);
// set rasterization mode
L_2DSetViewMode(L2D_USE_BEST);
// load the vector file as raster bitmap
L_INT nRet = L_LoadBitmap(dwgFileName, &bitmapFromVector, sizeof(BITMAPHANDLE), 24, ORDER_BGR, NULL, NULL);
if(SUCCESS == nRet)
{
// save output as JPG
nRet = L_SaveBitmap(jpegFileName, &bitmapFromVector, FILE_JPEG, 24, 2, NULL);
L_FreeBitmap(&bitmapFromVector);
}
If you would like to try it, there’s a free evaluation edition, which includes free tech support.