Module: Asposediagramjava::GetShapeIcon

Defined in:
lib/asposediagramjava/Shapes/getshapeicon.rb

Instance Method Summary collapse

Instance Method Details

#initializeObject



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/asposediagramjava/Shapes/getshapeicon.rb', line 3

def initialize()
    data_dir = File.dirname(File.dirname(File.dirname(File.dirname(__FILE__)))) + '/data/'

    # Create instance of Diagram
    diagram = Rjb::import('com.aspose.diagram.Diagram').new(data_dir + "Basic_Shapes.vsd")

    # get master
    master = diagram.getMasters().getMasterByName("Circle")
    
    # get byte array
    bytes = master.getIcon()
    
    # create an image file
    fos = Rjb::import('java.io.FileOutputStream').new(data_dir + "MyImage.png")
    
    # write byte array of the image
    fos.write(bytes)
    
    # close array
    fos.close()

    puts "Get shape icon, please check the output file."
end