The issue has just been added in our issue tracking system. We request for your patience and will share feedback with you as soon as the issue will be fixed.
We have verified the requirements w.r.t AutoCad 2019 behavior. It seems that the attached sample is has some incorrect internal data as different Autocad applications display it differently. Some even don’t display the image at all as well as rendering that. Therefore, we have the identical result as AutoCad 2019.
There is no dynamic option to achieve this. You will have to explicitly set bounds.
Thanks for your reply.
Could you please give some example of setting bounds using aspose code in java
You may consider using following sample code on your end to serve the purpose.
using (CadImage cadImage = (CadImage)Image.Load(fileName))
{
//get rasterimage entity for which we want to change export
CadRasterImage entity = (CadRasterImage) cadImage.Entities[cadImage.Entities.Length - 1];
//set clipping and boundaries
entity.ClippingState = 1;
entity.ClipBoundaryVertexList = new List<Cad2DPoint>() { new Cad2DPoint((double) 0,0), new Cad2DPoint(300,0), new Cad2DPoint(300,500), new Cad2DPoint(0,500) };
//now export
// cadImage.Save() ....
}
The above code is not solving my problem.
I need to fit the new image completely within my original space.
It can be done if we can set the width, height and scale of the image. Could you please let me know if we have the property in api for the same
RasterImage.PNG (246.7 KB)
if(entity.getTypeName()==CadEntityTypeName.IMAGE) {
CadRasterImage entity2 = (CadRasterImage) entity;
System.out.println(entity2.getInsertionPoint().getX());
}
In the above code we can get the insertion point of the image. similar can we set the length, width and scale of image
I have added the feedback shared in our issue tracking system and will share the further response with you as soon as it will be shared after investigation.
Hello,
Any updates. we want to purchase the library provided this issue is solved
At present the issue is still not fixed based on last observations shared by you. We will get back to you with feedback as soon as issue will be addressed.
Can you please try using following sample code on your end.
//For example, we have raterimage entity:
CadRasterImage rasterImage = ((CadRasterImage) cadImage.Entities[0]);
//origin image file size is:
//Width = rasterImage.ImageSizeU
//Height = rasterImage.ImageSizeV
//Total width and Height displayed in Autocad is:
var autocadDisplayedWidth = rasterImage.UVector.X * rasterImage.ImageSizeU;
var autocadDisplayedHeight = rasterImage.VVector.Y * rasterImage.ImageSizeV;
//To change it on rendering, please apply the folowing code, for example:
rasterImage.UVector.X *= 2;
rasterImage.VVector.Y *= 2;
Hello @mudassir.fayyaz
Thanks for your response. I have tried the code and it works.
Just one more query how to get the image name
RasterImage name.PNG (35.8 KB)
In the attached image, “logo-n”
As i have multiple images in the file, I need to apply scale factor based on image name
This will solve all my issues
Thanks & Regards,
Pranav C Lunavat
Hello,
It would be of great help if you could let me know the code to get the rasterimage name
Thanks & Regards,
Pranav C Lunavat
Actually, there is no property for this. Isn’t the same raster image file that you have loaded in your application.
Hello @mudassir.fayyaz
I have different (multiple) images in one dxf file.
Based on the image file name, I need to set the scale of the image as per the ratio of the dxf image width to actual image width.
In the attached dxf file i have 2 image.
- client.jpg
- billOfMaterial.jpg
now i want to set scale based on image name
CadImage cadImage = (CadImage) image;
for (CadBaseEntity entity : cadImage.getEntities()) {
if (entity.getTypeName() == CadEntityTypeName.IMAGE) {
CadRasterImage entity2 = (CadRasterImage) entity;
if (entity2.getImageName().equals("Client.jpg")) {
entity2.getUVector().setX(entity2.getUVector().getX() * 2);
entity2.getVVector().setY(entity2.getVVector().getY() * 2);
} else {
entity2.getUVector().setX(entity2.getUVector().getX() * 5);
entity2.getVVector().setY(entity2.getVVector().getY() * 5);
}
}
}
How can i get image name or image reference name something like entity2.getImageName().equals(“Client.jpg”)
multiple images.png (145.9 KB)
billOfMaterial.jpg (6.3 KB)
client.jpg (26.0 KB)
multiple images.zip (80.1 KB)
I have added an issue with ID CADJAVA-826 in our issue tracking system to investigate the requirement further and make provision in API for this. We will get back to you feedback as soon as it will be shared.
Hello,
Apart from the image name, there should also be provision to set the path of the image.
I have attached the image of the autocad window for the same
considering the previous code. something like
entity2.setPath("c:/newfile.jpg")
Image Path.jpg (212.0 KB)
I have added the information in our issue tracking system and will get back to you with feedback as soo as issue will be addressed.
Any update on the Issue CADJAVA-826
I regret to share that the issue is unresolved. We will share updates with you as soon as it will be addressed.
You can please try using following sample code snippet to find an image by name and image path update using latest Aspose.CAD for Java 20.11.
CadImage cadImage = (CadImage) Image.load(getPath(fileName));
for (ICadBaseEntity entity : cadImage.getEntities()) {
if (entity.getTypeName() == CadEntityTypeName.IMAGE) {
CadRasterImage rasterImage = ((CadRasterImage) entity);
String imagePath = null;
for (CadBaseObject baseObject : cadImage.getObjects())
{
if (baseObject.getTypeName() == CadObjectTypeName.IMAGEDEF) {
CadRasterImageDef imageDef = (CadRasterImageDef) baseObject;
if (imageDef.getObjectHandle().equals(rasterImage.getImageDefReference())) {
//image path was found
imagePath = imageDef.getFileName();
break;
}
}
}
if (imagePath.contains("client")) {
//some improvements to client image
}
}
}