public class ObjImage extends Image
Represents an image in OBJ format. Contains information about bounds of the drawing, materials, vertices, and shapes. Each shape contains information about set of faces with corresponding material, vertex, texture, and normal indices.
Loading of the drawing in OBJ format.using (ObjImage objImage = (ObjImage)Image.Load(fileName)) { ... }
| Constructor and Description |
|---|
ObjImage(ObjRoot objRoot)
Initializes a new instance of the
ObjImage class. |
| Modifier and Type | Method and Description |
|---|---|
void |
cacheData()
Caches the data and ensures no additional data loading will be performed from the underlying
DataStreamSupporter.DataStreamContainer(DataStreamSupporter#getDataStreamContainer/DataStreamSupporter#setDataStreamContainer_internalized(StreamContainer)). |
int |
getDepth()
Gets the depth of the image.
|
int |
getHeight()
Gets the height of the image.
|
ObjRoot |
getObjRoot()
Gets or sets root information about the drawing.
|
List<ObjShape> |
getShapes()
Gets data about drawable shapes for OBJ image.
|
int |
getWidth()
Gets the width of the image.
|
boolean |
isCached()
Gets a value indicating whether object's data is cached currently and no data reading is required.
|
canLoad, canLoad, canLoad, canLoad, canSave, getAnnotationService, getBounds, getContainer, getCustomProperties, getFileFormat, getFileFormat, getPalette, getSize, getStrings, getUnitlessDefaultUnitType, getUnitType, getWatermarkGuardService, load, load, load, load, load, save, save, save, setPalettegetDataStreamContainer, save, save, save, saveclose, dispose, getDisposedpublic ObjImage(ObjRoot objRoot)
Initializes a new instance of the ObjImage class.
Creates new ObjRoot object, fills it with vertices and single face, exports into PNG format.ObjRoot root = new ObjRoot(); root.Materials.Add(new ObjMaterial() { Diffuse = new Obj3Values(1, 0, 0) }); root.Vertices.Add(new ObjVertex(0, 0, 0)); root.Vertices.Add(new ObjVertex(100, 100, 100)); root.Vertices.Add(new ObjVertex(100, 200, 300)); ObjShape newShape = new ObjShape(); newShape.MaterialId = root.Materials.Count - 1; ObjFace newFace = new ObjFace(); newFace.VertexTextureNormals.Add(new ObjVertexTextureNormalIndex() { VertexIndex = root.Vertices.Count - 3 }); newFace.VertexTextureNormals.Add(new ObjVertexTextureNormalIndex() { VertexIndex = root.Vertices.Count - 2 }); newFace.VertexTextureNormals.Add(new ObjVertexTextureNormalIndex() { VertexIndex = root.Vertices.Count - 1 }); newShape.Faces.Add(newFace); root.Shapes.Add(newShape); using (ObjImage newImage = new ObjImage(root)) { CadRasterizationOptions options = new CadRasterizationOptions(); options.PageHeight = 300; options.PageWidth = 300; options.DrawType = CadDrawTypeMode.UseObjectColor; newImage.Save(outputPngFile, new PngOptions() { VectorRasterizationOptions = options}); };
objRoot - ObjRoot object with vertices and shapes.public final ObjRoot getObjRoot()
Gets or sets root information about the drawing. ObjRoot contains data about vertices, materials, and shapes. Could be useful for the exposing information about faces.
Prints the overall quantity of vertices in the OBJ drawing.using (ObjImage objImage = (ObjImage)Image.Load(fileName)) { ObjRoot rootInformation = objImage.ObjRoot; System.Console.WriteLine("The drawing has {0} vertices", rootInformation.Vertices.Count); }
public int getWidth()
Gets the width of the image. Calculated as the difference between maximum and minimum values of the X coordinate amongst all vertices. Minimal allowed width is 1.
Value: The width of the image.Prints the width of the OBJ drawing.using (ObjImage objImage = (ObjImage)Image.Load(fileName)) { System.Console.WriteLine("The width of the image is {0}", objImage.Width); }
getWidth in interface IObjectWithBoundsgetWidth in class Imagepublic int getHeight()
Gets the height of the image. Calculated as the difference between maximum and minimum values of the Y coordinate amongst all vertices. Minimal allowed height is 1.
Value: The height of the image.Prints the height of the OBJ drawing.using (ObjImage objImage = (ObjImage)Image.Load(fileName)) { System.Console.WriteLine("The height of the image is {0}", objImage.Height); }
getHeight in interface IObjectWithBoundsgetHeight in class Imagepublic int getDepth()
Gets the depth of the image. Calculated as the difference between maximum and minimum values of the Z coordinate amongst all vertices. Minimal allowed depth is 0.
Value: The depth of the image.Prints the depth of the OBJ drawing.using (ObjImage objImage = (ObjImage)Image.Load(fileName)) { System.Console.WriteLine("The depth of the image is {0}", objImage.Depth); }
public boolean isCached()
Gets a value indicating whether object's data is cached currently and no data reading is required.
Value:true if object's data is cached; otherwise, false.isCached in class DataStreamSupporterpublic final List<ObjShape> getShapes()
Gets data about drawable shapes for OBJ image. Each shape contains information about its name, material and faces. ObjFace includes data about correspoinding vertex, texture, and normal indices.
Prints the quantity of faces in each shape.using (ObjImage objImage = (ObjImage)Image.Load(fileName)) { foreach (ObjShape shape in objImage.GetShapes()) { System.Console.WriteLine("Shape has {0} faces", shape.Faces.Count); } }
public void cacheData()
Caches the data and ensures no additional data loading will be performed from the underlying DataStreamSupporter.DataStreamContainer(DataStreamSupporter#getDataStreamContainer/DataStreamSupporter#setDataStreamContainer_internalized(StreamContainer)).
Not implemented.
cacheData in class DataStreamSupportercom.aspose.ms.System.NotImplementedExceptionCopyright (c) 2008-2025 Aspose Pty Ltd. All Rights Reserved.