3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
# File 'lib/asposeimagingjava/photoshop/createpsd.rb', line 3
def initialize()
data_dir = File.dirname(File.dirname(File.dirname(File.dirname(__FILE__)))) + '/data/'
create_options = Rjb::import('com.aspose.imaging.imageoptions.PsdOptions').new
create_options.setSource(Rjb::import('com.aspose.imaging.sources.FileCreateSource').new(data_dir + "CreatePSD.psd", false))
create_options.setColorMode(Rjb::import('com.aspose.imaging.fileformats.psd.ColorModes').Indexed)
create_options.setVersion(5)
color = Rjb::import('com.aspose.imaging.Color')
palette = [color.getRed(), color.getGreen(), color.getBlue()]
create_options.setPalette(Rjb::import('com.aspose.imaging.fileformats.psd.PsdColorPalette').new(palette))
create_options.setCompressionMethod(Rjb::import('com.aspose.imaging.fileformats.psd.CompressionMethod').RLE)
psd = Rjb::import('com.aspose.imaging.fileformats.psd.PsdImage').create(create_options, 500, 500)
graphics = Rjb::import('com.aspose.imaging.Graphics').new(psd)
graphics.clear(color.getWhite())
graphics.drawEllipse(Rjb::import('com.aspose.imaging.Pen').new(color.getRed(), 6), Rjb::import('com.aspose.imaging.Rectangle').new(0, 0, 400, 400))
psd.save()
puts "Created PSD successfully!"
end
|