Class: GdkPixbuf::Pixbuf
- Inherits:
-
Object
- Object
- GdkPixbuf::Pixbuf
- Extended by:
- GLib::Deprecatable
- Defined in:
- lib/gdk_pixbuf2/pixbuf.rb,
lib/gdk_pixbuf2/deprecated.rb
Class Method Summary collapse
Instance Method Summary collapse
- #composite(options) ⇒ Object
- #composite!(source, options) ⇒ Object
- #composite_raw ⇒ Object
- #dup ⇒ Object
- #fill!(pixel) ⇒ Object
-
#initialize(*args) ⇒ Pixbuf
constructor
A new instance of Pixbuf.
- #initialize_raw ⇒ Object
- #rotate(angle) ⇒ Object
- #saturate_and_pixelate(saturation, pixelate) ⇒ Object
- #saturate_and_pixelate_raw ⇒ Object
- #save(*args) ⇒ Object
-
#scale(*args) ⇒ Object
TODO: test TODO: Improve API by Hash.
-
#scale!(source, *args) ⇒ Object
TODO: test TODO: Improve API by Hash.
- #scale_raw ⇒ Object
Constructor Details
#initialize(*args) ⇒ Pixbuf
Returns a new instance of Pixbuf.
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/gdk_pixbuf2/pixbuf.rb', line 21 def initialize(*args) case args.size when 1 case args[0] when Hash initialize_with_hash(args[0]) when String = "#{caller[0]}: #{self.class}.new(path) is deprecated. " << "Use #{self.class}.new(:file => path) instead." warn initialize_raw(args[0]) when Array = "#{caller[0]}: #{self.class}.new(xpm) is deprecated. " << "Use #{self.class}.new(:xpm => xpm) instead." warn initialize_new_from_xpm_data(args[0]) else raise ArgumentError, "must be options: #{args[0].inspect}" end when 2 = "#{caller[0]}: " << "#{self.class}.new(data, copy_pixels) is deprecated. " << "Use Gio::Resource instead." warn initialize_from_inline(*args) when 3 = "#{caller[0]}: " << "#{self.class}.new(path, width, height) is deprecated. " << "Use #{self.class}.new(:file => path, :width => width, " << ":height => height) instead." warn initialize_new_from_file_at_size(*args) when 4 = "#{caller[0]}: " << "#{self.class}.new(path, width, height, " << "preserve_aspect_ratio) is deprecated. " << "Use #{self.class}.new(:file => path, :width => width, " << ":height => height, " << ":preserve_aspect_ratio => preserve_aspect_ratio) instead." warn initialize_new_from_file_at_scale(*args) when 5 = "#{caller[0]}: " << "#{self.class}.new(colorspace, has_alpha, bits_per_sample, " << "width, height) is deprecated. " << "Use #{self.class}.new(:colorspace => colorspace, " << ":has_alpha => has_alpha, " << ":bits_per_sample => bits_per_sample, " << ":width => width, " << ":height => height) instead." warn initialize_new(*args) when 7 = "#{caller[0]}: " << "#{self.class}.new(data, colorspace, has_alpha, " << "bits_per_sample, width, height) is deprecated. " << "Use #{self.class}.new(:data => data, " << ":colorspace => colorspace, " << ":has_alpha => has_alpha, " << ":bits_per_sample => bits_per_sample, " << ":width => width, " << ":height => height) instead." warn initialize_new_from_data(*args) else super end end |
Class Method Details
.new(*args, &block) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/gdk_pixbuf2/deprecated.rb', line 26 def new(*args, &block) if args[0].is_a?(Pixbuf) = "#{caller[0]}: #{self}.new(pixbuf, ...) is deprecated. " << "Use pixbuf.subpixbuf(...) instead." warn() args[0].subpixbuf(*args[1..-1]) elsif args.size == 1 and args[0].is_a?(Hash) = args[0] src_pixbuf = [:src_pixbuf] if src_pixbuf = "#{caller[0]}: " << "#{self}.new(:src_pixbuf => pixbuf, ...) is deprecated. " << "Use pixbuf.subpixbuf(...) instead." warn() src_pixbuf.subpixbuf([:src_x], [:src_y], [:width], [:height]) else super end else super end end |
Instance Method Details
#composite(options) ⇒ Object
306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 |
# File 'lib/gdk_pixbuf2/pixbuf.rb', line 306 def composite() destination = [:destination] || [:dest] dest_x = [:destination_x] || [:dest_x] || 0 dest_y = [:destination_y] || [:dest_y] || 0 dest_width = [:destination_width] || [:dest_width] dest_height = [:destination_height] || [:dest_height] destination ||= Pixbuf.new(:colorspace => colorspace, :has_alpha => has_alpha?, :bits_per_sample => bits_per_sample, :width => dest_x + dest_width, :height => dest_y + dest_height) destination.composite!(self, ) destination end |
#composite!(source, options) ⇒ Object
322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 |
# File 'lib/gdk_pixbuf2/pixbuf.rb', line 322 def composite!(source, ) dest_x = [:destination_x] || [:dest_x] || 0 dest_y = [:destination_y] || [:dest_y] || 0 dest_width = [:destination_width] || [:dest_width] dest_height = [:destination_height] || [:dest_height] offset_x = [:offset_x] || 0.0 offset_y = [:offset_y] || 0.0 scale_x = [:scale_x] || (dest_width / source.width.to_f) scale_y = [:scale_y] || (dest_height / source.height.to_f) interpolation_type = [:interpolation_type] || [:interp_type] || :bilinear overall_alpha = [:overall_alpha] || 255 check_x = [:check_x] || 0 check_y = [:check_y] || 0 check_size = [:check_size] color1 = [:color1] || 0x999999 color2 = [:color2] || 0xdddddd if check_size source.composite_color(self, dest_x, dest_y, dest_width, dest_height, offset_x, offset_y, scale_x, scale_y, interpolation_type, overall_alpha, check_x, check_y, check_size, color1, color2) else source.composite_raw(self, dest_x, dest_y, dest_width, dest_height, offset_x, offset_y, scale_x, scale_y, interpolation_type, overall_alpha) end end |
#composite_raw ⇒ Object
305 |
# File 'lib/gdk_pixbuf2/pixbuf.rb', line 305 alias_method :composite_raw, :composite |
#dup ⇒ Object
177 178 179 |
# File 'lib/gdk_pixbuf2/pixbuf.rb', line 177 def dup copy end |
#fill!(pixel) ⇒ Object
187 188 189 |
# File 'lib/gdk_pixbuf2/pixbuf.rb', line 187 def fill!(pixel) fill(pixel) end |
#initialize_raw ⇒ Object
19 |
# File 'lib/gdk_pixbuf2/pixbuf.rb', line 19 alias_method :initialize_raw, :initialize |
#rotate(angle) ⇒ Object
191 192 193 |
# File 'lib/gdk_pixbuf2/pixbuf.rb', line 191 def rotate(angle) rotate_simple(angle) end |
#saturate_and_pixelate(saturation, pixelate) ⇒ Object
196 197 198 199 200 |
# File 'lib/gdk_pixbuf2/pixbuf.rb', line 196 def saturate_and_pixelate(saturation, pixelate) dest = dup saturate_and_pixelate_raw(dest, saturation, pixelate) dest end |
#saturate_and_pixelate_raw ⇒ Object
195 |
# File 'lib/gdk_pixbuf2/pixbuf.rb', line 195 alias_method :saturate_and_pixelate_raw, :saturate_and_pixelate |
#save(type, options = {}) ⇒ String, void #save(filename, type, options = {}) ⇒ void
227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 |
# File 'lib/gdk_pixbuf2/pixbuf.rb', line 227 def save(*args) case args.size when 1 arg1 = args[0] if arg1.respond_to?(:to_path) filename = arg1.to_path elsif arg1.is_a?(String) and arg1.include?(".") filename = args[0] else filename = nil type = arg1 end if filename type = File.extname(filename).gsub(/\A\./, "").downcase case type when "jpg" type = "jpeg" end end = {} when 2 if args.last.is_a?(Hash) type, = args if .key?(:filename) = .dup filename = .delete(:filename) else filename = nil end else filename, type = args = {} end when 3 filename, type, = args else = "wrong number of arguments (given #{args.size}, expected 1..3)" raise ArgumentError, end keys = [] values = [] .each do |key, value| key = key.to_s if key.is_a?(Symbol) keys << key values << value end if filename savev(filename, type, keys, values) else _, data = save_to_bufferv(type, keys, values) data.pack("C*") end end |
#scale(*args) ⇒ Object
TODO: test TODO: Improve API by Hash
285 286 287 288 289 290 291 292 293 294 |
# File 'lib/gdk_pixbuf2/pixbuf.rb', line 285 def scale(*args) case args.size when 2, 3 width, height, interp_type = args interp_type ||= :bilinear scale_simple(width, height, interp_type) else scale_raw(*args) end end |
#scale!(source, *args) ⇒ Object
TODO: test TODO: Improve API by Hash
298 299 300 301 302 303 |
# File 'lib/gdk_pixbuf2/pixbuf.rb', line 298 def scale!(source, *args) if args.size == 8 args << :bilinear end source.scale_raw(self, *args) end |
#scale_raw ⇒ Object
282 |
# File 'lib/gdk_pixbuf2/pixbuf.rb', line 282 alias_method :scale_raw, :scale |