OpenGL-Image

 view release on metacpan or  search on metacpan

Image.pod  view on Meta::CPAN

=head1 NAME

  OpenGL::Image - v1.03 copyright 2007 Graphcomp - ALL RIGHTS RESERVED
  Author: Bob "grafman" Free - grafman@graphcomp.com
  Contributor: Geoff Broadwell

  This program is free software; you can redistribute it and/or
  modify it under the same terms as Perl itself.


=head1 DESCRIPTION

  This module is an extensible wrapper to abstract imaging interfaces

  By default, this module uses the OpenGL::Image::Targa module; support for
  other imaging libraries may be added by providing plug-in modules
  in the OpenGL/Image folder.

  An OpenGL::Image::Magick module is also provided for use with
  PerlMagick.  For best performance, ImageMagick 6.3.5 or newer should
  be installed.


=head1 SYNOPSIS

  ##########
  # Check for installed imaging engines
  use OpenGL::Image;

  # Get hashref of installed imaging engines
  # Keys are engine names; values are info hashes, including version,
  # priority (1 .. n, 1 is highest), module (Perl module name)
  # and description.
  # Priority can be set using Engines.lst (see INSTALL); otherwise
  # 'Targa' has top priority, and others are in unspecified order.
  my $engine_hashref = OpenGL::Image::GetEngines();

  # In list context, returns list of info hashes sorted by engine
  # priority; info hash does not include a priority value.
  my @sorted_engine_info = OpenGL::Image::GetEngines();

  # Check for a specific engine and optional version support
  # Returns an info hashref for the engine if available; otherwise undef.
  my $info_hashref = OpenGL::Image::HasEngine('Magick','6.3.5');


  ##########
  # Load texture - defaults to highest priority engine if none specified;
  # if Engines.lst is not specified, the highest priority is the Targa engine.
  my $tex = new OpenGL::Image(source=>'test.tga');

  # Get GL info
  my($ifmt,$fmt,$type) = $tex->Get('gl_internalformat','gl_format','gl_type');
  my($w,$h) = $tex->Get('width','height');

  # Test if power of 2
  if (!$tex->IsPowerOf2()) return;

  # Set texture  
  glTexImage2D_c(GL_TEXTURE_2D, 0, $ifmt, $w, $h, 0, $fmt, $type, $tex->Ptr());


  ##########
  # Modify GL frame using ImageMagick
  my $frame = new OpenGL::Image(engine=>'Magick',width=>$w,height=>$h);

  # Get default GL info
  my($def_fmt,$def_type) = $tex->Get('gl_format','gl_type');

  # Read frame pixels
  glReadPixels_c(0, 0, $width, $height, $def_fmt, $def_type, $frame->Ptr());

  # Sync native image buffer
  # Must use this prior to making native calls
  $frame->Sync();

  # Modify frame pixels
  $frame->Native->Blur();



( run in 0.557 second using v1.01-cache-2.11-cpan-39bf76dae61 )