⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 imagegd.pm

📁 PDF-API2-0.2.3.7_dev.tar.gz
💻 PM
字号:
#==================================================================
#	Text::PDF::ImageGD
#==================================================================
package Text::PDF::ImageGD;

use strict;
use Text::PDF::Dict;
use Text::PDF::Utils;
use Text::PDF::Image;
use vars qw(@ISA);

@ISA = qw(Text::PDF::Image);

=head2 Text::PDF::ImageGD

=item $img = Text::PDF::ImageGD->new $pdf,$name, $gdobj

Returns a new image object from a gd object.

=cut

sub new {
	my ($class,$pdf,$name,$gd)=@_;
	my $self = $class->SUPER::new($pdf,$name);
	my ($w,$h)=$gd->getBounds();

	$self->width($w);
	$self->height($h);
	$self->bpc(8);
        $self->colorspace('DeviceRGB');

	if(UNIVERSAL::can($gd,'jpeg')) {
		$self->filters('DCTDecode');
		$self->{' nofilt'}=1;
		$self->{' stream'}=$gd->jpeg(100);
	} else {
		$self->filters('FlateDecode');
		my($x,$y);
		for($y=0;$y<$h;$y++) {
			for($x=0;$x<$w;$x++) {
				my $index=$gd->getPixel($x,$y);
				my @rgb=$gd->rgb($index);
				$self->{' stream'}.=pack('CCC',@rgb);
			}
		}
	}

	return($self);
}

1;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -