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
|
# File 'lib/asposeimagingjava/images/addwatermarktoimage.rb', line 3
def initialize()
data_dir = File.dirname(File.dirname(File.dirname(File.dirname(__FILE__)))) + '/data/'
image = Rjb::import('com.aspose.imaging.Image').load(data_dir + "aspose.bmp")
graphics = Rjb::import('com.aspose.imaging.Graphics').new(image)
font = Rjb::import('com.aspose.imaging.Font').new("Times New Roman", 16, Rjb::import('com.aspose.imaging.FontStyle').Bold)
brush = Rjb::import('com.aspose.imaging.brushes.SolidBrush').new
brush.setColor(Rjb::import('com.aspose.imaging.Color').getBlack())
brush.setOpacity(100)
graphics.drawString("Aspose.Imaging for Ruby", font, brush, Rjb::import('com.aspose.imaging.PointF').new(image.getWidth()-100, image.getHeight()-100))
image.save(data_dir + "out.bmp")
puts "Watermark added successfully!"
end
|