PHP.mk документација

imagepalettecopy

Почист и полокален преглед на PHP референцата, со задржана структура од PHP.net и подобра читливост за примери, секции и белешки.

function.imagepalettecopy.php PHP.net прокси Преводот се освежува
Оригинал на PHP.net
Патека function.imagepalettecopy.php Локална патека за оваа страница.
Извор php.net/manual/en Оригиналниот HTML се реупотребува и локално се стилизира.
Режим Прокси + превод во позадина Кодовите, табелите и белешките остануваат читливи во истиот тек.
imagepalettecopy

Референца за `function.imagepalettecopy.php` со подобрена типографија и навигација.

function.imagepalettecopy.php

imagepalettecopy

(PHP 4 >= 4.0.1, PHP 5, PHP 7, PHP 8)

imagepalettecopyКопирај ја палетата од една слика на друга

= NULL

imagepalettecopy(GdImage $dst, GdImage $src): void

imagepalettecopy() копирај ја палетата од src слика на dst image.

Параметри

dst

Објектот на целната слика.

src

Објектот на изворната слика.

Вратени вредности

Не се враќа вредност.

Дневник на промени

Верзија = NULL
8.0.0 dst and src expect GdImage Сликата објект што ќе се користи како плочка. resourceинстанци сега; претходно,

Примери

Пример #1 imagepalettecopy() example

<?php
// Create two palette images
$palette1 = imagecreate(100, 100);
$palette2 = imagecreate(100, 100);

// Allocate the background to be
// green in the first palette image
$green = imagecolorallocate($palette1, 0, 255, 0);

// Copy the palette from image 1 to image 2
imagepalettecopy($palette2, $palette1);

// Since the palette is now copied we can use the
// green color allocated to image 1 without using
// imagecolorallocate() twice
imagefilledrectangle($palette2, 0, 0, 99, 99, $green);

// Output image to the browser
header('Content-type: image/png');

imagepng($palette2);
?>

Белешки од корисници 2 забелешки

buzz на nospam dot oska dot com
20 години пред
actually it doesn't "copy" the palette exactly.  It copys the colors from the source palette to the destination image.   the palette you end up with in the destination image will be "same colors different order".   If you want an EXACT palette copy (at the expense of messing up your image if you aren't careful), then use this code: 
<?
// this is a drop-in replacement for imagepalettecopy, except that it make NO attempt to modifiy any of the 
// colors in the dest image, just the palette.   The result?  if you're palette's aren't very similar, the image will look completely different, and likely terrible!
function imagepalettecopy_exact ( $dst_img, $src_img) {
    for( $c = 0 ; $c < imagecolorstotal($src_img); $c++) {
        $col = imagecolorsforindex($src_img,$c);  //get color at index 'c' in the color table
        imagecolorset($dst_img,$c,$col[red],$col[green],$col[blue]); //set color at index 'c' to $col in the $dst_image
    }
}

?>
Los Olvidados
пред 23 години
To be precise, this function replaces the palette in the destination.
Навигација

Прелистувај сродни теми и функции.

На оваа страница

Автоматски outline од активната документација.

Насловите ќе се појават тука по вчитување.

Попрегледно читање

Примерите, changelog табелите и user notes се визуелно издвоени за да не се губат во долгата содржина.

Брз совет Користи го outline-от Скокни директно на главните секции од активната страница.
Извор Оригиналниот линк останува достапен Кога ти треба целосен upstream context, отвори го PHP.net во нов tab.