public class PaletteReducer
extends java.lang.Object
AnimatedGif
and PNG8
, but it is meant to help with intelligently reducing the color count to fit under the maximum
palette size for those formats. You can use the exact(Color[])
method or its overloads to match a specific
palette exactly, or the analyze(Pixmap)
method or its overloads to analyze one or more Pixmaps and determine
which colors are most frequently-used. If using this class on its own, after calling exact(), analyze(), or a
constructor that uses them, you can use a specific dithering algorithm to reduce a Pixmap to the current palette.
Dithering algorithms that this supports:
reduceFloydSteinberg(Pixmap)
(Floyd-Steinberg is a very common error-diffusion dither; it's
excellent for still images and large palette sizes, but not animations. It is great for preserving shape, but
when a color isn't in the palette and it needs to try to match it, Floyd-Steinberg can leave artifacts.)reduceScatter(Pixmap)
(This is Floyd-Steinberg, as above, but with some of the problem artifacts
that Floyd-Steinberg can produce perturbed by blue noise; it's the default here because it works well in still
images and animations. Using blue noise to edit error somewhat-randomly would seem like it would introduce
artifacts of its own, but blue noise patterns are very hard to recognize as artificial, since they show up mostly
in organic forms.)reduceJimenez(Pixmap)
(This is a modified version of Gradient Interleaved Noise by Jorge Jimenez;
it's a kind of ordered dither that introduces a subtle wave pattern to break up solid blocks. It does quite well
on some animations and on smooth or rounded shapes.)reduceKnollRoberts(Pixmap)
(This is a modified version of Thomas Knoll's Pattern Dithering; it skews
a grid-based ordered dither and also does a small amount of gamma correction, so lightness may change. It
preserves shape extremely well, but is almost never 100% faithful to the original colors. It has gotten much
better since version 0.2.4, however. This algorithm is rather slow; most of the other algorithms take comparable
amounts of time to each other, but KnollRoberts and especially Knoll are sluggish.)reduceChaoticNoise(Pixmap)
(Uses blue noise and pseudo-random white noise, with a carefully chosen
distribution, to disturb what would otherwise be flat bands. This does introduce chaotic or static-looking
pixels, but with larger palettes they won't be far from the original. This works fine as a last resort when you
can tolerate chaotic/fuzzy patches of poorly-defined shapes, but other dithers aren't doing well.)reduceBlueNoise(Pixmap)
(Uses a blue noise texture, which has almost no apparent patterns, to adjust
the amount of color correction applied to each mismatched pixel; also uses a quasi-random pattern. This may not
add enough disruption to some images, which leads to a flat-looking result.)reduceSierraLite(Pixmap)
(Like Floyd-Steinberg, Sierra Lite is an error-diffusion dither, and it
sometimes looks better than Floyd-Steinberg, but usually is similar or worse unless the palette is small. If
Floyd-Steinberg has unexpected artifacts, you can try Sierra Lite, and it may avoid those issues. Using
Scatter should be tried first, though.)reduceKnoll(Pixmap)
(Thomas Knoll's Pattern Dithering, used more or less verbatim except for the
inclusion of some gamma correction; this version has a heavy grid pattern that looks like an artifact. The skew
applied to Knoll-Roberts gives it a more subtle triangular grid, while the square grid here is a bit bad. This
reduction is the slowest here, currently, and may noticeably delay processing on large images.)reduceSolid(Pixmap)
(No dither! Solid colors! Mostly useful when you want to preserve blocky parts
of a source image, or for some kinds of pixel/low-color art.)Created by Tommy Ettinger on 6/23/2018.
| Modifier and Type | Field and Description |
|---|---|
int |
colorCount |
static int[] |
HALTONIC
This 255-color (plus transparent) palette uses the (3,5,7) Halton sequence to get 3D points, treats those as IPT
channel values, and rejects out-of-gamut colors.
|
static double[][] |
IPT
Stores IPT components corresponding to RGB555 indices.
|
static float[][] |
OKLAB
Stores Oklab components corresponding to RGB555 indices.
|
int[] |
paletteArray
The RGBA8888 int colors this can reduce an image to use.
|
byte[] |
paletteMapping
Stores the byte indices into
paletteArray (when treated as unsigned; mask with 255) corresponding to
RGB555 colors (you can get an RGB555 int from an RGBA8888 int using shrink(int) ). |
static byte[] |
RAW_BLUE_NOISE
This should always be a 4096-element byte array filled with 64 sections of 64 bytes each.
|
static byte[] |
TRI_BLUE_NOISE
Very similar to
RAW_BLUE_NOISE , a 4096-element byte array as a 64x64 grid of bytes. |
static double[] |
TRI_BLUE_NOISE_MULTIPLIERS
A 64x64 grid of doubles, with a median value of about 1.0, generated using the triangular-distributed blue noise
from
TRI_BLUE_NOISE . |
| Constructor and Description |
|---|
PaletteReducer()
Constructs a default PaletteReducer that uses the "Haltonic" 255-color-plus-transparent palette.
|
PaletteReducer(com.badlogic.gdx.utils.Array<com.badlogic.gdx.graphics.Pixmap> pixmaps)
Constructs a PaletteReducer that analyzes the given Pixmaps for color count and frequency to generate a palette
(see
analyze(Array) )} for more info). |
PaletteReducer(com.badlogic.gdx.graphics.Color[] colorPalette)
Constructs a PaletteReducer that uses the given array of Color objects as a palette (see
exact(Color[])
for more info). |
PaletteReducer(com.badlogic.gdx.graphics.Color[] colorPalette,
int limit)
Constructs a PaletteReducer that uses the given array of Color objects as a palette (see
exact(Color[], int) for more info). |
PaletteReducer(int[] rgbaPalette)
Constructs a PaletteReducer that uses the given array of RGBA8888 ints as a palette (see
exact(int[])
for more info). |
PaletteReducer(int[] palette,
byte[] preload)
Constructs a PaletteReducer that uses the given array of RGBA8888 ints as a palette (see
exact(int[], byte[]) for more info) and an encoded byte array to use to look up pre-loaded color data. |
PaletteReducer(int[] rgbaPalette,
int limit)
Constructs a PaletteReducer that uses the given array of RGBA8888 ints as a palette (see
exact(int[], int) for more info). |
PaletteReducer(com.badlogic.gdx.graphics.Pixmap pixmap)
Constructs a PaletteReducer that analyzes the given Pixmap for color count and frequency to generate a palette
(see
analyze(Pixmap) for more info). |
PaletteReducer(com.badlogic.gdx.graphics.Pixmap pixmap,
int threshold)
Constructs a PaletteReducer that analyzes the given Pixmap for color count and frequency to generate a palette
(see
analyze(Pixmap, int) for more info). |
| Modifier and Type | Method and Description |
|---|---|
PaletteReducer |
alterColorsIPT(com.badlogic.gdx.math.Interpolation lightness,
com.badlogic.gdx.math.Interpolation greenToRed,
com.badlogic.gdx.math.Interpolation blueToYellow)
Edits this PaletteReducer by changing each used color in the IPT color space with an
Interpolation . |
PaletteReducer |
alterColorsLightness(com.badlogic.gdx.math.Interpolation lightness)
Edits this PaletteReducer by changing each used color in the IPT color space with an
Interpolation . |
void |
analyze(com.badlogic.gdx.utils.Array<com.badlogic.gdx.graphics.Pixmap> pixmaps)
Analyzes all of the Pixmap items in
pixmaps for color count and frequency (as if they are one image),
building a palette with at most 256 colors. |
void |
analyze(com.badlogic.gdx.utils.Array<com.badlogic.gdx.graphics.Pixmap> pixmaps,
int threshold)
Analyzes all of the Pixmap items in
pixmaps for color count and frequency (as if they are one image),
building a palette with at most 256 colors. |
void |
analyze(com.badlogic.gdx.utils.Array<com.badlogic.gdx.graphics.Pixmap> pixmaps,
int threshold,
int limit)
Analyzes all of the Pixmap items in
pixmaps for color count and frequency (as if they are one image),
building a palette with at most limit colors. |
void |
analyze(com.badlogic.gdx.graphics.Pixmap pixmap)
Analyzes
pixmap for color count and frequency, building a palette with at most 256 colors if there are
too many colors to store in a PNG-8 palette. |
void |
analyze(com.badlogic.gdx.graphics.Pixmap[] pixmaps,
int pixmapCount,
int threshold,
int limit)
Analyzes all of the Pixmap items in
pixmaps for color count and frequency (as if they are one image),
building a palette with at most limit colors. |
void |
analyze(com.badlogic.gdx.graphics.Pixmap pixmap,
int threshold)
Analyzes
pixmap for color count and frequency, building a palette with at most 256 colors if there are
too many colors to store in a PNG-8 palette. |
void |
analyze(com.badlogic.gdx.graphics.Pixmap pixmap,
int threshold,
int limit)
Analyzes
pixmap for color count and frequency, building a palette with at most limit colors. |
void |
analyzeMC(com.badlogic.gdx.graphics.Pixmap pixmap,
int limit) |
int |
blend(int rgba1,
int rgba2,
double preference) |
protected void |
compareSwap(int[] ints,
int a,
int b)
Compares items in ints by their luma, looking up items by the indices a and b, and swaps the two given indices if
the item at a has higher luma than the item at b.
|
static double |
difference(int color1,
int color2) |
static double |
difference(int color1,
int r2,
int g2,
int b2) |
static double |
difference(int r1,
int g1,
int b1,
int r2,
int g2,
int b2) |
void |
exact(com.badlogic.gdx.graphics.Color[] colorPalette)
Builds the palette information this PaletteReducer stores from the Color objects in
colorPalette , up to
256 colors. |
void |
exact(com.badlogic.gdx.graphics.Color[] colorPalette,
int limit)
Builds the palette information this PaletteReducer stores from the Color objects in
colorPalette , up to
256 colors or limit , whichever is less. |
void |
exact(int[] rgbaPalette)
Builds the palette information this PNG8 stores from the RGBA8888 ints in
rgbaPalette , up to 256 colors. |
void |
exact(int[] palette,
byte[] preload)
Builds the palette information this PaletteReducer stores from the given array of RGBA8888 ints as a palette (see
exact(int[]) for more info) and an encoded byte array to use to look up pre-loaded color data. |
void |
exact(int[] rgbaPalette,
int limit)
Builds the palette information this PNG8 stores from the RGBA8888 ints in
rgbaPalette , up to 256 colors
or limit , whichever is less. |
PaletteReducer |
hueShift()
Edits this PaletteReducer by changing each used color so lighter colors lean towards warmer hues, while darker
colors lean toward cooler or more purple-ish hues.
|
int |
iptToRgb(double i,
double p,
double t,
double a) |
static byte[] |
loadPreloadFile(com.badlogic.gdx.files.FileHandle file)
If you saved a preload file with
writePreloadFile(FileHandle) , you can load it and give it to a
constructor with: new PaletteReducer(intColors, PaletteReducer.loadPreloadFile(theFile)) , where intColors
is the original int array of RGBA8888 colors and theFile is the preload file written previously. |
static int |
oklabToRGB(double L,
double A,
double B,
double alpha) |
int |
randomColor(java.util.Random random)
Retrieves a random non-transparent color from the palette this would reduce to, with a higher likelihood for
colors that are used more often in reductions (those with few similar colors).
|
byte |
randomColorIndex(java.util.Random random)
Retrieves a random non-0 color index for the palette this would reduce to, with a higher likelihood for colors
that are used more often in reductions (those with few similar colors).
|
com.badlogic.gdx.graphics.Pixmap |
reduce(com.badlogic.gdx.graphics.Pixmap pixmap)
Modifies the given Pixmap so it only uses colors present in this PaletteReducer, dithering when it can
using Scatter dithering (this merely delegates to
reduceScatter(Pixmap) ). |
com.badlogic.gdx.graphics.Pixmap |
reduce(com.badlogic.gdx.graphics.Pixmap pixmap,
Dithered.DitherAlgorithm ditherAlgorithm)
Uses the given
Dithered.DitherAlgorithm to decide how to dither pixmap . |
com.badlogic.gdx.graphics.Pixmap |
reduceBlueNoise(com.badlogic.gdx.graphics.Pixmap pixmap)
A blue-noise-based dither; does not diffuse error, and uses a tiling blue noise pattern (which can be accessed
with
RAW_BLUE_NOISE , but shouldn't usually be modified) as well as a fine-grained checkerboard pattern
and a roughly-white-noise pattern obtained by distorting th blue noise, but only applies these noisy pattern
when there's error matching a color from the image to a color in the palette. |
com.badlogic.gdx.graphics.Pixmap |
reduceChaoticNoise(com.badlogic.gdx.graphics.Pixmap pixmap)
A white-noise-based dither; uses the colors encountered so far during dithering as a sort of state for basic
pseudo-random number generation, while also using some blue noise from a tiling texture to offset clumping.
|
float |
reduceFloat(float packedColor)
Looks up
color as if it was part of an image being color-reduced and finds the closest color to it in the
palette this holds. |
com.badlogic.gdx.graphics.Pixmap |
reduceFloydSteinberg(com.badlogic.gdx.graphics.Pixmap pixmap)
Modifies the given Pixmap so it only uses colors present in this PaletteReducer, dithering when it can using the
commonly-used Floyd-Steinberg dithering.
|
byte |
reduceIndex(int color)
Looks up
color as if it was part of an image being color-reduced and finds the closest color to it in the
palette this holds. |
com.badlogic.gdx.graphics.Color |
reduceInPlace(com.badlogic.gdx.graphics.Color color)
Modifies
color so its RGB values will match the closest color in this PaletteReducer's palette. |
com.badlogic.gdx.graphics.Pixmap |
reduceJimenez(com.badlogic.gdx.graphics.Pixmap pixmap) |
com.badlogic.gdx.graphics.Pixmap |
reduceKnoll(com.badlogic.gdx.graphics.Pixmap pixmap)
Reduces a Pixmap to the palette this knows by using Thomas Knoll's pattern dither, which is out-of-patent since
late 2019.
|
com.badlogic.gdx.graphics.Pixmap |
reduceKnollRoberts(com.badlogic.gdx.graphics.Pixmap pixmap)
Reduces a Pixmap to the palette this knows by using a skewed version of Thomas Knoll's pattern dither, which is
out-of-patent since late 2019, using the harmonious numbers rediscovered by Martin Roberts to handle the skew.
|
com.badlogic.gdx.graphics.Pixmap |
reduceScatter(com.badlogic.gdx.graphics.Pixmap pixmap)
Modifies the given Pixmap so it only uses colors present in this PaletteReducer, using Floyd-Steinberg to dither
but modifying patterns slightly by introducing triangular-distributed blue noise.
|
com.badlogic.gdx.graphics.Pixmap |
reduceSierraLite(com.badlogic.gdx.graphics.Pixmap pixmap)
Modifies the given Pixmap so it only uses colors present in this PaletteReducer, dithering when it can using
Sierra Lite dithering instead of the Floyd-Steinberg dithering that
reduce(Pixmap) uses. |
int |
reduceSingle(int color)
Looks up
color as if it was part of an image being color-reduced and finds the closest color to it in the
palette this holds. |
com.badlogic.gdx.graphics.Pixmap |
reduceSolid(com.badlogic.gdx.graphics.Pixmap pixmap)
Modifies the given Pixmap so it only uses colors present in this PaletteReducer, without dithering.
|
void |
setDefaultPalette()
Resets the palette to the 256-color (including transparent) "Haltonic" palette.
|
void |
setDitherStrength(float ditherStrength)
Changes the "strength" of the dither effect applied during
reduce(Pixmap) calls. |
static int |
shrink(int color)
Converts an RGBA8888 int color to the RGB555 format used by
IPT to look up colors. |
static int |
stretch(int color)
Converts an RGB555 int color to an approximation of the closest RGBA8888 color.
|
void |
writePreloadFile(com.badlogic.gdx.files.FileHandle file)
If this PaletteReducer has already calculated a palette, you can use this to save the slightly-slow-to-compute
palette mapping in a preload file for later runs.
|
public static final int[] HALTONIC
public static final double[][] IPT
(r << 10 | g << 5 | b)
, where r,
g, and b are all in the 0-31 range inclusive. It's usually easiest to convert an RGBA8888 int color to an RGB555
color with shrink(int)
.public static final float[][] OKLAB
(r << 10 | g << 5 | b)
, where r,
g, and b are all in the 0-31 range inclusive. It's usually easiest to convert an RGBA8888 int color to an RGB555
color with shrink(int)
.public static byte[] RAW_BLUE_NOISE
public static byte[] TRI_BLUE_NOISE
RAW_BLUE_NOISE
, a 4096-element byte array as a 64x64 grid of bytes. Unlike RAW, this
uses a triangular distribution for its bytes, so values near 0 are much more common. This is only used inside
this library to create TRI_BLUE_NOISE_MULTIPLIERS
, which is used in reduceScatter(Pixmap)
.
public static double[] TRI_BLUE_NOISE_MULTIPLIERS
TRI_BLUE_NOISE
. If you randomly selected two doubles from this and multiplied them, the average
result should be 1.0; half should be between 1 and Math.E
, and the other half should the inverses of the
first half (between 1.0/Math.E
and 1).
public final byte[] paletteMapping
paletteArray
(when treated as unsigned; mask with 255) corresponding to
RGB555 colors (you can get an RGB555 int from an RGBA8888 int using shrink(int)
). This is not especially
likely to be useful externally except to make a preload code for later usage. If you have a way to write and read
bytes from a file, you can calculate a frequently-used palette once using exact(int[])
or
analyze(Pixmap)
, write this field to file, and on later runs you can load the 32768-element byte array
to speed up construction using PaletteReducer(int[], byte[])
. Editing this field is strongly
discouraged; use exact(int[])
or analyze(Pixmap)
to set the palette as a whole.public final int[] paletteArray
exact(int[])
when you want to change the colors
available, and treat this array as read-only. If you don't call exact() or analyze(Pixmap)
to set the
values in this, then the reductions that use gamma correction (reduceKnoll(Pixmap)
,
reduceKnollRoberts(Pixmap)
, and any Dithered
using
Dithered.DitherAlgorithm.PATTERN
) will be incorrect.public int colorCount
public PaletteReducer()
public PaletteReducer(int[] rgbaPalette)
exact(int[])
for more info).rgbaPalette
- an array of RGBA8888 ints to use as a palettepublic PaletteReducer(int[] rgbaPalette, int limit)
exact(int[], int)
for more info).rgbaPalette
- an array of RGBA8888 ints to use as a palettelimit
- how many int items to use from rgbaPalette (this always starts at index 0)public PaletteReducer(com.badlogic.gdx.graphics.Color[] colorPalette)
exact(Color[])
for more info).colorPalette
- an array of Color objects to use as a palettepublic PaletteReducer(com.badlogic.gdx.graphics.Color[] colorPalette, int limit)
exact(Color[], int)
for more info).colorPalette
- an array of Color objects to use as a palettepublic PaletteReducer(com.badlogic.gdx.graphics.Pixmap pixmap)
analyze(Pixmap)
for more info).pixmap
- a Pixmap to analyze in detail to produce a palettepublic PaletteReducer(com.badlogic.gdx.utils.Array<com.badlogic.gdx.graphics.Pixmap> pixmaps)
analyze(Array)
)} for more info).pixmaps
- an Array of Pixmap to analyze in detail to produce a palettepublic PaletteReducer(int[] palette, byte[] preload)
exact(int[], byte[])
for more info) and an encoded byte array to use to look up pre-loaded color data.
You can use writePreloadFile(FileHandle)
to write the preload data for a given PaletteReducer, and
loadPreloadFile(FileHandle)
to get a byte array of preload data from a previously-written file.palette
- an array of RGBA8888 ints to use as a palettepreload
- a byte array containing preload datapublic PaletteReducer(com.badlogic.gdx.graphics.Pixmap pixmap, int threshold)
analyze(Pixmap, int)
for more info).pixmap
- a Pixmap to analyze in detail to produce a palettethreshold
- the minimum difference between colors required to put them in the palette (default 150)public static int shrink(int color)
IPT
to look up colors.color
- an RGBA8888 int colorpublic static int stretch(int color)
color
, this gets an 8-bit value by keeping the original 5 in the most significant 5 places, then copying
the most significant 3 bits of the RGB555 color into the least significant 3 bits of the 8-bit value. In
practice, this means the lowest 5-bit value produces the lowest 8-bit value (00000 to 00000000), and the highest
5-bit value produces the highest 8-bit value (11111 to 11111111). This always assigns a fully-opaque value to
alpha (255, or 0xFF).color
- an RGB555 colorpublic int iptToRgb(double i, double p, double t, double a)
public static int oklabToRGB(double L, double A, double B, double alpha)
public void writePreloadFile(com.badlogic.gdx.files.FileHandle file)
intColors
), you can load it when constructing a
PaletteReducer with new PaletteReducer(intColors, PaletteReducer.loadPreloadFile(theFile))
.file
- a writable non-null FileHandle; this will overwrite a file already present if it has the same namepublic static byte[] loadPreloadFile(com.badlogic.gdx.files.FileHandle file)
writePreloadFile(FileHandle)
, you can load it and give it to a
constructor with: new PaletteReducer(intColors, PaletteReducer.loadPreloadFile(theFile))
, where intColors
is the original int array of RGBA8888 colors and theFile is the preload file written previously.file
- a readable non-null FileHandle that should have been written by
writePreloadFile(FileHandle)
, or otherwise contain the bytes of paletteMapping
PaletteReducer(int[], byte[])
public static double difference(int color1, int color2)
public static double difference(int color1, int r2, int g2, int b2)
public static double difference(int r1, int g1, int b1, int r2, int g2, int b2)
public void setDefaultPalette()
public void exact(int[] rgbaPalette)
rgbaPalette
, up to 256 colors.
Alpha is not preserved except for the first item in rgbaPalette, and only if it is 0
(fully transparent
black); otherwise all items are treated as opaque. If rgbaPalette is null, empty, or only has one color, then
this defaults to the "Haltonic" palette with 256 well-distributed colors (including transparent).rgbaPalette
- an array of RGBA8888 ints; all will be used up to 256 items or the length of the arraypublic void exact(int[] rgbaPalette, int limit)
rgbaPalette
, up to 256 colors
or limit
, whichever is less.
Alpha is not preserved except for the first item in rgbaPalette, and only if it is 0
(fully transparent
black); otherwise all items are treated as opaque. If rgbaPalette is null, empty, or only has one color, or if
limit is less than 2, then this defaults to the "Haltonic" palette with 256 well-distributed colors (including
transparent).rgbaPalette
- an array of RGBA8888 ints; all will be used up to 256 items or the length of the arraylimit
- a limit on how many int items to use from rgbaPalette; useful if rgbaPalette is from an IntArraypublic void exact(int[] palette, byte[] preload)
exact(int[])
for more info) and an encoded byte array to use to look up pre-loaded color data. The
encoded byte array can be copied out of the paletteMapping
of an existing PaletteReducer, or just as
likely you can use ENCODED_HALTONIC
as a nice default. There's slightly more startup time spent when
initially calling exact(int[])
, but it will produce the same result. You can store the paletteMapping
from that PaletteReducer once, however you want to store it, and send it back to this on later runs.palette
- an array of RGBA8888 ints to use as a palettepreload
- a byte array with exactly 32768 (or 0x8000) items, containing paletteMapping
datapublic void exact(com.badlogic.gdx.graphics.Color[] colorPalette)
colorPalette
, up to
256 colors.
Alpha is not preserved except for the first item in colorPalette, and only if its r, g, b, and a values are all
0f (fully transparent black); otherwise all items are treated as opaque. If rgbaPalette is null, empty, or only
has one color, then this defaults to the "Haltonic" palette with 256 well-distributed colors (including
transparent).colorPalette
- an array of Color objects; all will be used up to 256 items or the length of the arraypublic void exact(com.badlogic.gdx.graphics.Color[] colorPalette, int limit)
colorPalette
, up to
256 colors or limit
, whichever is less.
Alpha is not preserved except for the first item in colorPalette, and only if its r, g, b, and a values are all
0f (fully transparent black); otherwise all items are treated as opaque. If rgbaPalette is null, empty, only has
one color, or limit is less than 2, then this defaults to the "Haltonic" palette with 256 well-distributed
colors (including transparent).colorPalette
- an array of Color objects; all will be used up to 256 items, limit, or the length of the arraylimit
- a limit on how many Color items to use from colorPalette; useful if colorPalette is from an Arraypublic void analyze(com.badlogic.gdx.graphics.Pixmap pixmap)
pixmap
for color count and frequency, building a palette with at most 256 colors if there are
too many colors to store in a PNG-8 palette. If there are 256 or less colors, this uses the exact colors
(although with at most one transparent color, and no alpha for other colors); if there are more than 256 colors
or any colors have 50% or less alpha, it will reserve a palette entry for transparent (even if the image has no
transparency). Because calling reduce(Pixmap)
(or any of PNG8's write methods) will dither colors that
aren't exact, and dithering works better when the palette can choose colors that are sufficiently different, this
uses a threshold value to determine whether it should permit a less-common color into the palette, and if the
second color is different enough (as measured by difference(int, int)
) by a value of at least 150, it is
allowed in the palette, otherwise it is kept out for being too similar to existing colors. This doesn't return a
value but instead stores the palette info in this object; a PaletteReducer can be assigned to the
PNG8.palette
field or can be used directly to reduce(Pixmap)
a Pixmap.pixmap
- a Pixmap to analyze, making a palette which can be used by this to reduce(Pixmap)
or by PNG8public void analyze(com.badlogic.gdx.graphics.Pixmap pixmap, int threshold)
pixmap
for color count and frequency, building a palette with at most 256 colors if there are
too many colors to store in a PNG-8 palette. If there are 256 or less colors, this uses the exact colors
(although with at most one transparent color, and no alpha for other colors); if there are more than 256 colors
or any colors have 50% or less alpha, it will reserve a palette entry for transparent (even if the image has no
transparency). Because calling reduce(Pixmap)
(or any of PNG8's write methods) will dither colors that
aren't exact, and dithering works better when the palette can choose colors that are sufficiently different, this
takes a threshold value to determine whether it should permit a less-common color into the palette, and if the
second color is different enough (as measured by difference(int, int)
) by a value of at least
threshold
, it is allowed in the palette, otherwise it is kept out for being too similar to existing
colors. The threshold is usually between 100 and 1000, and 150 is a good default. Because this always uses the
maximum color limit, threshold should be lower than cases where the color limit is small. If the threshold is too
high, then some colors that would be useful to smooth out subtle color changes won't get considered, and colors
may change more abruptly. This doesn't return a value but instead stores the palette info in this object; a
PaletteReducer can be assigned to the PNG8.palette
or AnimatedGif.palette
fields or can be used
directly to reduce(Pixmap)
a Pixmap.pixmap
- a Pixmap to analyze, making a palette which can be used by this to reduce(Pixmap)
or by PNG8threshold
- a minimum color difference as produced by difference(int, int)
; usually between 100 and 1000, 150 is a good defaultpublic void analyze(com.badlogic.gdx.graphics.Pixmap pixmap, int threshold, int limit)
pixmap
for color count and frequency, building a palette with at most limit
colors.
If there are limit
or less colors, this uses the exact colors (although with at most one transparent
color, and no alpha for other colors); if there are more than limit
colors or any colors have 50% or less
alpha, it will reserve a palette entry for transparent (even if the image has no transparency). Because calling
reduce(Pixmap)
(or any of PNG8's write methods) will dither colors that aren't exact, and dithering
works better when the palette can choose colors that are sufficiently different, this takes a threshold value to
determine whether it should permit a less-common color into the palette, and if the second color is different
enough (as measured by difference(int, int)
) by a value of at least threshold
, it is allowed in
the palette, otherwise it is kept out for being too similar to existing colors. The threshold is usually between
100 and 1000, and 150 is a good default. If the threshold is too high, then some colors that would be useful to
smooth out subtle color changes won't get considered, and colors may change more abruptly. This doesn't return a
value but instead stores the palette info in this object; a PaletteReducer can be assigned to the
PNG8.palette
or AnimatedGif.palette
fields, or can be used directly to reduce(Pixmap)
a
Pixmap.pixmap
- a Pixmap to analyze, making a palette which can be used by this to reduce(Pixmap)
or by PNG8threshold
- a minimum color difference as produced by difference(int, int)
; usually between 100 and 1000, 150 is a good defaultlimit
- the maximum number of colors to allow in the resulting palette; typically no more than 256public void analyzeMC(com.badlogic.gdx.graphics.Pixmap pixmap, int limit)
public int blend(int rgba1, int rgba2, double preference)
public void analyze(com.badlogic.gdx.utils.Array<com.badlogic.gdx.graphics.Pixmap> pixmaps)
pixmaps
for color count and frequency (as if they are one image),
building a palette with at most 256 colors. If there are 256 or less colors, this uses the
exact colors (although with at most one transparent color, and no alpha for other colors); if there are more than
256 colors or any colors have 50% or less alpha, it will reserve a palette entry for transparent (even
if the image has no transparency). Because calling reduce(Pixmap)
(or any of PNG8's write methods) will
dither colors that aren't exact, and dithering works better when the palette can choose colors that are
sufficiently different, this takes a threshold value to determine whether it should permit a less-common color
into the palette, and if the second color is different enough (as measured by difference(int, int)
) by a
value of at least 150, it is allowed in the palette, otherwise it is kept out for being too similar to existing
colors. This doesn't return a value but instead stores the palette info in this object; a PaletteReducer can be
assigned to the PNG8.palette
or AnimatedGif.palette
fields, or can be used directly to
reduce(Pixmap)
a Pixmap.pixmaps
- a Pixmap Array to analyze, making a palette which can be used by this to reduce(Pixmap)
, by AnimatedGif, or by PNG8public void analyze(com.badlogic.gdx.utils.Array<com.badlogic.gdx.graphics.Pixmap> pixmaps, int threshold)
pixmaps
for color count and frequency (as if they are one image),
building a palette with at most 256 colors. If there are 256 or less colors, this uses the
exact colors (although with at most one transparent color, and no alpha for other colors); if there are more than
256 colors or any colors have 50% or less alpha, it will reserve a palette entry for transparent (even
if the image has no transparency). Because calling reduce(Pixmap)
(or any of PNG8's write methods) will
dither colors that aren't exact, and dithering works better when the palette can choose colors that are
sufficiently different, this takes a threshold value to determine whether it should permit a less-common color
into the palette, and if the second color is different enough (as measured by difference(int, int)
) by a
value of at least threshold
, it is allowed in the palette, otherwise it is kept out for being too similar
to existing colors. The threshold is usually between 100 and 1000, and 150 is a good default. This doesn't return
a value but instead stores the palette info in this object; a PaletteReducer can be assigned to the
PNG8.palette
or AnimatedGif.palette
fields, or can be used directly to
reduce(Pixmap)
a Pixmap.pixmaps
- a Pixmap Array to analyze, making a palette which can be used by this to reduce(Pixmap)
, by AnimatedGif, or by PNG8threshold
- a minimum color difference as produced by difference(int, int)
; usually between 100 and 1000, 150 is a good defaultpublic void analyze(com.badlogic.gdx.utils.Array<com.badlogic.gdx.graphics.Pixmap> pixmaps, int threshold, int limit)
pixmaps
for color count and frequency (as if they are one image),
building a palette with at most limit
colors. If there are limit
or less colors, this uses the
exact colors (although with at most one transparent color, and no alpha for other colors); if there are more than
limit
colors or any colors have 50% or less alpha, it will reserve a palette entry for transparent (even
if the image has no transparency). Because calling reduce(Pixmap)
(or any of PNG8's write methods) will
dither colors that aren't exact, and dithering works better when the palette can choose colors that are
sufficiently different, this takes a threshold value to determine whether it should permit a less-common color
into the palette, and if the second color is different enough (as measured by difference(int, int)
) by a
value of at least threshold
, it is allowed in the palette, otherwise it is kept out for being too similar
to existing colors. The threshold is usually between 100 and 1000, and 150 is a good default. This doesn't return
a value but instead stores the palette info in this object; a PaletteReducer can be assigned to the
PNG8.palette
or AnimatedGif.palette
fields, or can be used directly to
reduce(Pixmap)
a Pixmap.pixmaps
- a Pixmap Array to analyze, making a palette which can be used by this to reduce(Pixmap)
, by AnimatedGif, or by PNG8threshold
- a minimum color difference as produced by difference(int, int)
; usually between 100 and 1000, 150 is a good defaultlimit
- the maximum number of colors to allow in the resulting palette; typically no more than 256public void analyze(com.badlogic.gdx.graphics.Pixmap[] pixmaps, int pixmapCount, int threshold, int limit)
pixmaps
for color count and frequency (as if they are one image),
building a palette with at most limit
colors. If there are limit
or less colors, this uses the
exact colors (although with at most one transparent color, and no alpha for other colors); if there are more than
limit
colors or any colors have 50% or less alpha, it will reserve a palette entry for transparent (even
if the image has no transparency). Because calling reduce(Pixmap)
(or any of PNG8's write methods) will
dither colors that aren't exact, and dithering works better when the palette can choose colors that are
sufficiently different, this takes a threshold value to determine whether it should permit a less-common color
into the palette, and if the second color is different enough (as measured by difference(int, int)
) by a
value of at least threshold
, it is allowed in the palette, otherwise it is kept out for being too similar
to existing colors. The threshold is usually between 100 and 1000, and 150 is a good default. This doesn't return
a value but instead stores the palette info in this object; a PaletteReducer can be assigned to the
PNG8.palette
or AnimatedGif.palette
fields, or can be used directly to
reduce(Pixmap)
a Pixmap.pixmaps
- a Pixmap array to analyze, making a palette which can be used by this to reduce(Pixmap)
, by AnimatedGif, or by PNG8pixmapCount
- the maximum number of Pixmap entries in pixmaps to usethreshold
- a minimum color difference as produced by difference(int, int)
; usually between 100 and 1000, 150 is a good defaultlimit
- the maximum number of colors to allow in the resulting palette; typically no more than 256public void setDitherStrength(float ditherStrength)
reduce(Pixmap)
calls. The default is 1f,
and while both values higher than 1f and lower than 1f are valid, they should not be negative. If you want dither
to be eliminated, don't set dither strength to 0; use reduceSolid(Pixmap)
instead of reduce().
If ditherStrength is too high, all sorts of artifacts will appear; if it is too low, the effect of the dither to
smooth out changes in color will be very hard to notice.ditherStrength
- dither strength as a non-negative float that should be close to 1fpublic com.badlogic.gdx.graphics.Pixmap reduce(com.badlogic.gdx.graphics.Pixmap pixmap)
reduceScatter(Pixmap)
).
If you want to reduce the colors in a Pixmap based on what it currently contains, call
analyze(Pixmap)
with pixmap
as its argument, then call this method with the same
Pixmap. You may instead want to use a known palette instead of one computed from a Pixmap;
exact(int[])
is the tool for that job.pixmap
- a Pixmap that will be modified in placepublic com.badlogic.gdx.graphics.Pixmap reduce(com.badlogic.gdx.graphics.Pixmap pixmap, Dithered.DitherAlgorithm ditherAlgorithm)
Dithered.DitherAlgorithm
to decide how to dither pixmap
.pixmap
- a pixmap that will be modified in-placeditherAlgorithm
- a dithering algorithm enum value; if not recognized, defaults to Dithered.DitherAlgorithm.SCATTER
pixmap
after modificationspublic com.badlogic.gdx.graphics.Pixmap reduceSolid(com.badlogic.gdx.graphics.Pixmap pixmap)
analyze(Pixmap)
with pixmap
as its argument, then call this method with the same
Pixmap. You may instead want to use a known palette instead of one computed from a Pixmap;
exact(int[])
is the tool for that job.pixmap
- a Pixmap that will be modified in placepublic com.badlogic.gdx.graphics.Pixmap reduceSierraLite(com.badlogic.gdx.graphics.Pixmap pixmap)
reduce(Pixmap)
uses.
If you want to reduce the colors in a Pixmap based on what it currently contains, call
analyze(Pixmap)
with pixmap
as its argument, then call this method with the same
Pixmap. You may instead want to use a known palette instead of one computed from a Pixmap;
exact(int[])
is the tool for that job.
This method is similar to Floyd-Steinberg, since both are error-diffusion dithers. Sometimes Sierra Lite can avoid unpleasant artifacts in Floyd-Steinberg, so it's better in the worst-case, but it isn't usually as good in its best-case.
pixmap
- a Pixmap that will be modified in placepublic com.badlogic.gdx.graphics.Pixmap reduceFloydSteinberg(com.badlogic.gdx.graphics.Pixmap pixmap)
analyze(Pixmap)
with pixmap
as its argument, then call this method with the same
Pixmap. You may instead want to use a known palette instead of one computed from a Pixmap;
exact(int[])
is the tool for that job.pixmap
- a Pixmap that will be modified in placepublic com.badlogic.gdx.graphics.Pixmap reduceJimenez(com.badlogic.gdx.graphics.Pixmap pixmap)
public com.badlogic.gdx.graphics.Pixmap reduceBlueNoise(com.badlogic.gdx.graphics.Pixmap pixmap)
RAW_BLUE_NOISE
, but shouldn't usually be modified) as well as a fine-grained checkerboard pattern
and a roughly-white-noise pattern obtained by distorting th blue noise, but only applies these noisy pattern
when there's error matching a color from the image to a color in the palette.pixmap
- will be modified in-place and returnedpublic com.badlogic.gdx.graphics.Pixmap reduceChaoticNoise(com.badlogic.gdx.graphics.Pixmap pixmap)
reduceBlueNoise(Pixmap)
, permitting more pixels to be different from
what reduceSolid(Pixmap)
would produce, but this generally looks good, especially with larger palettes.pixmap
- will be modified in-place and returnedpublic com.badlogic.gdx.graphics.Pixmap reduceScatter(com.badlogic.gdx.graphics.Pixmap pixmap)
analyze(Pixmap)
with pixmap
as its
argument, then call this method with the same Pixmap. You may instead want to use a known palette instead of one
computed from a Pixmap; exact(int[])
is the tool for that job.pixmap
- a Pixmap that will be modified in placeprotected void compareSwap(int[] ints, int a, int b)
reduceKnoll(Pixmap)
. Uses
OKLAB
to look up accurate luma for the given colors in ints
(that contains RGBA8888 colors
while OKLAB uses RGB555, so shrink(int)
is used to convert).ints
- an int array than must be able to take a and b as indices; may be modified in placea
- an index into intsb
- an index into intspublic com.badlogic.gdx.graphics.Pixmap reduceKnoll(com.badlogic.gdx.graphics.Pixmap pixmap)
setDitherStrength(float)
. At close-up zooms, a strong grid pattern will be visible
on most dithered output (like needlepoint). The algorithm was described in detail by Joel Yliluoma in
this dithering article. Yliluoma used an 8x8
threshold matrix because at the time 4x4 was still covered by the patent, but using 4x4 allows a much faster
sorting step (this uses a sorting network, which works well for small input sizes like 16 items). This is still
very significantly slower than the other dithers here (except for reduceKnollRoberts(Pixmap)
.
pixmap
- a Pixmap that will be modifiedpixmap
, after modificationsAn alternative that uses a similar pattern but skews it to obscure the grid
public com.badlogic.gdx.graphics.Pixmap reduceKnollRoberts(com.badlogic.gdx.graphics.Pixmap pixmap)
setDitherStrength(float)
. A hexagonal pattern can be visible on many outputs this produces;
this artifact can be mitigated by lowering dither strength. The algorithm was described in detail by Joel
Yliluoma in this dithering article. Yliluoma used an
8x8 threshold matrix because at the time 4x4 was still covered by the patent, but using 4x4 allows a much faster
sorting step (this uses a sorting network, which works well for small input sizes like 16 items). This is stil
very significantly slower than the other dithers here (except for reduceKnoll(Pixmap)
.
pixmap
- a Pixmap that will be modifiedpixmap
, after modificationsAn alternative that uses a similar pattern but has a more obvious grid
public byte randomColorIndex(java.util.Random random)
(palette.randomColorIndex(random) & 255)
, can be used as an index into a
palette array with 256 or less elements that should have been used with exact(int[])
before to set the
palette this uses.random
- a Random instance, which may be seededpublic int randomColor(java.util.Random random)
Color.rgba8888ToColor(Color, int)
or
Color.set(int)
.random
- a Random instance, which may be seededpublic int reduceSingle(int color)
color
as if it was part of an image being color-reduced and finds the closest color to it in the
palette this holds. Both the parameter and the returned color are RGBA8888 ints.color
- an RGBA8888 int that represents a color this should try to find a similar color for in its palettepublic byte reduceIndex(int color)
color
as if it was part of an image being color-reduced and finds the closest color to it in the
palette this holds. The parameter is a RGBA8888 int, the returned color is a byte index into the
paletteArray
(mask it like: paletteArray[reduceIndex(color) & 0xFF]
).color
- an RGBA8888 int that represents a color this should try to find a similar color for in its palettepaletteArray
public float reduceFloat(float packedColor)
color
as if it was part of an image being color-reduced and finds the closest color to it in the
palette this holds. Both the parameter and the returned color are packed float colors, as produced by
Color.toFloatBits()
or many methods in SColor.packedColor
- a packed float color this should try to find a similar color for in its palettepublic com.badlogic.gdx.graphics.Color reduceInPlace(com.badlogic.gdx.graphics.Color color)
color
so its RGB values will match the closest color in this PaletteReducer's palette. If color
has Color.a
less than 0.5f, this will simply set color to be fully transparent, with rgba all 0.color
- a libGDX Color that will be modified in-place; do not use a Color constant, use Color.cpy()
or a temporary Colorpublic PaletteReducer alterColorsLightness(com.badlogic.gdx.math.Interpolation lightness)
Interpolation
.
This allows adjusting lightness, such as for gamma correction. You could use Interpolation.pow2InInverse
to use the square root of a color's lightness instead of its actual lightness, or Interpolation.pow2In
to
square the lightness instead.lightness
- an Interpolation that will affect the lightness of each colorpublic PaletteReducer alterColorsIPT(com.badlogic.gdx.math.Interpolation lightness, com.badlogic.gdx.math.Interpolation greenToRed, com.badlogic.gdx.math.Interpolation blueToYellow)
Interpolation
.
This allows adjusting lightness, such as for gamma correction, but also individually emphasizing or
de-emphasizing different aspects of the chroma. You could use Interpolation.pow2InInverse
to use the
square root of a color's lightness instead of its actual lightness, or Interpolation.pow2In
to square the
lightness instead. You could make colors more saturated by passing Interpolation.circle
to greenToRed and
blueToYellow, or get a less-extreme version by using Interpolation.smooth
. To desaturate colors is a
different task; you can create a OtherMath.BiasGain
Interpolation with 0.5 turning and maybe 0.25 to 0.75 shape to
produce different strengths of desaturation. Using a shape of 1.5 to 4 with BiasGain is another way to saturate
the colors.lightness
- an Interpolation that will affect the lightness of each colorgreenToRed
- an Interpolation that will make colors more green if it evaluates below 0.5 or more red otherwiseblueToYellow
- an Interpolation that will make colors more blue if it evaluates below 0.5 or more yellow otherwisepublic PaletteReducer hueShift()


--- layout: post status: publish published: true title: Enjoy Your Webcam on Your Mac author: Leask author_login: leask author_email<EMAIL_ADDRESS>author_url: https://leaskh.com wordpress_id: 521 wordpress_url: http://leaskh.wordpress.com/2006/06/23/enjoy-your-webcam-on-your-mac date: '2006-06-23 17:47:14 +0800' date_gmt: '2006-06-23 17:47:14 +0800' categories: - Computers and Internet tags: [] comments: [] ---


PIRCS Intranet
Internal systems information
This page contains information regarding internal systems and procedures for the PIRCS equipment. As such its access will be controlled to certain domains.
Installed Software Index
Sample form for user accounts
User accounts
The items below are under development (as is everything here really)
code developement and analysis (tools on
the PIRCS systems)
Visualization: Xess, Spyglass, etc.
html authoring tools
systems admin (account management and creation, NFS, tape units, etc.)
resources (WWW and similar)
Thursday. April 2nd, 97
Thur., March 13: 1997
Wed., March 12: 1997
NFS is up and running, I have a 26 gig volume exported to pircsa0 for
testing and it is looking good.
I will bring the printers and accounts up next and the compilers will
be installed as well today. On that note I have not heard back form the
comp cernter regarding compilers for the alpha's so I will get back in
touch with them, it's been over a week now.
Mon., March 10: 1997
Sorry for all the delays in providing updates here, it has been wild getting everything together plus not falling behind on my other projects. (I have of course fallen behind on the projects anyway) Here is the status of events, it looks to all soon be done and up.
Thur., Feb 27: 1997
Wed., Feb 26: 1997
Some people have asked if they will always have to deal with changing passwords on all the different machines. Absolutely not. The server will run NIS (yellow pages) so you will be able to deal with centralized passwords and file systems, including home directories. I will provide more information on this as well as some easy mods to your dot files so that you don't have to worry if you are on the SGI's, alpha's or vincent machines.
Tuesday, Feb 25: 1997
The accounts are ready (no really, they are) and I will bring over the info and drop it off (the username and temp passwds) The following notes will be on the account sheet:
Send your problems/complaints/fashion tips to<EMAIL_ADDRESS>and I will deal with them.
Tuesday, Feb 18: 1997
Sunday, Feb 16: 1997
I am working up most of my notes here so that people will have a single
page to reference to see the status of efforts. I will try to keep this
up-to-date, clean and easy to use. If you have anything you would like
to see here or any comments, please let me know.
Reference Section
Very early development stage
Making user accounts
There are a few things to keep in mind in reference to making user
accounts on the systems. One is that if someone already has a Vincent
computer account you should use their UID from Vincent for the UID on
all the systems. You can get this from Vincent with the command:
hesinfo username passwd
For example:
hesinfo fils passwd
fils:*:1316:101:Douglas R Fils,89B Physics,(515) 294-6196,(515)
292-0597,:/home/fils:/bin/tcsh
This shows my vincent UID to be 1316.
I will work up a detailed page on the steps to add users to the various machines, as well the the chlist additions for the vincent stations. Also, a common root passwd should be decided upon for the machines so that the popper people can be provided with this access.
NFS notes
When the drives arrive and are installed, I will use a common mount
point on all the NFS clients. Due to some restrictions with the mount
point on vincent workstations (NFS mount points only allowed in /local)
I am suggesting:
/local/mnt/nfs0
as the mount point on all the machines. This path can then be used in the code and it can be compiled on the SGI's, Alpha's, Vincent, etc and the path name will be common to all. I will sym link this on the O2000 as well, so even it will be able to use this directory path.
The mount command (must be executed as root) is then:
mount -tnfs pricss0.geol.iastate.edu:/usr/people/pircs /local/mnt/nfs0
this is only an example, until the machine is here, I can't put the
actual command
Printer notes
The LaserJet 5 is currently named LaserJet 5, I will get this changed
to something more like pircs_lj5 soon. When that is done I will put
details here on adding printers and how to print to them. The SGI's are
currently pointed at this printer, so the command
lp -dlaserejt5 file
will print to it. Note this is a SysV style lp system, not BSD style
lpr system as most people at ISU are used to. I will install the BSD
lpr package on the SGI's so both can be used. I will redo this section
as the printer details get refined.
HINT marks
As Prof. Arritt, has noted the only good benchmark is the program
itself. I couldn't agree more, however, I have a high degree of respect
for the HINT system developed at Ames Lab. As such I provide you a very
early look at the results I have for machines like those being used by
PIRCS.
In addition to the common caveats related to benchmarks I provide these as well.
isofs image files
As some data may be distributed in CD-ROM format, I will install the
isofs program. This is a UNIX side program we are using to generate iso
image files. Most all common CD-ROM writing software can read these
format files. It allows for the creation of the CD-ROM
"image" on the UNIX side which can help preserve proper path
and file names and also helps to increase speed and reliability in the
creation of CD-ROM's. Currently this program exists for the IRIX
systems, I think I can compile it OK on the Dec UNIX systems though as
well.
Tape reference
I will expand this section later with more details and information
regarding reading, writing and tape manipulation. Multi-tape archives,
moving forward and backward in multi-archive tapes, etc.
For now I will note the following tapes as supported:
X server on the PC's and xhosting notes
I have software for both the Windows and Mac computer to allow them to
xhost to the UNIX machines. This can be done to Vincent as well, but
the Dec Alpha's on vincent require that I create some /local/etc files
to setup the permissions correctly (The ULTRIX boxes don't require
these edits).
I will configure these programs and place information here on their use as well as general information about xhosting here.
Network topology
I worked up a quick layout of how I am currently planning the room.
Please ignore scaling aspects, this is only for location references. As
always, this is your room, please let me know if you have any ideas or
problems with my working plans.
I will add details here regarding computer type, configuration, IP information, OS type, etc. It is because I do plan to put this information here that I strongly suggest making this page viewable to a restricted set of people and or domains.


WITNESS LIST State Recreational Resources Committee (Subcommittee on Hunting License Exemptions) August 21, 2000-10:00A Hunting License Exemptions For: Joiner, Gary (Texas Farm Bureau) On: Sinclair, David (Texas Parks and Wildlife) Registering, but not testifying: On: King, Jack (Texas Parks and Wildlife)


Every feedback you provide matters the world to us.
Would you recommend our product to a friend/family?
What would you like to see improved? (Check all that apply)


- Journal List
- HHS Author Manuscripts
- PMC1459289
Pharmacokinetic interaction between nelfinavir and pravastatin in HIV-seronegative volunteers: ACTG Study A5108
Abstract
Background: Nelfinavir, an HIV protease inhibitor with numerous drug–drug interactions, is associated with dyslipidemia. Pravastatin is the preferred statin prescribed for HIV-associated dyslipidemia.
Objective: To examine the effect of nelfinavir on pravastatin pharmacokinetics.
Design: Open-label study in healthy HIV-seronegative adults conducted at the AIDS Clinical Trials Group sites in the United States.
Methods: Subjects received pravastatin 40 mg daily and underwent intensive sampling for pharmacokinetics on day 3. Subjects took only nelfinavir 1250 mg twice daily on days 4–12. On days 13–15, subjects continued nelfinavir and reinitiated pravastatin. Plasma samples were collected over 24 h for the calculation of pravastatin area under the concentration–time curve for 0–24 h on days 3 and 16.
Results: Data from 14 subjects with complete pharmacokinetic samples were available for analysis. The median within-subject percentage change in pravastatin AUC was a decrease of 46.5%. Pravastatin maximum plasma concentrations were also lower when pravastatin was administered with nelfinavir. Median values for the maximum plasma concentrations were 27.9 and 12.4 ng/ml for days 3 and 16, respectively, and the median within-subject decrease was 40.1%.
Conclusions: Coadministration of pravastatin and nelfinavir led to a substantial reduction in pravastatin plasma concentrations. Higher doses of pravastatin may need to be prescribed in order to achieve optimal lipid-lowering activity.
Introduction
Nelfinavir (NFV) is an HIV protease inhibitor (PI) that has demonstrated numerous drug–drug interactions and is also associated with dyslipidemia, which may require lipid-lowering therapy [1]. This therapy uses 3-hydroxy-3-methylglutaryl coenzyme A reductase inhibitors known as statins. In a previous study, we demonstrated that simvastatin should not be used with ritonavir/saquinavir because of the large increases in plasma concentrations from inhibition of CYP3A4 metabolism [2]. Similarly, atorvastatin exposure was also increased by CYP3A4 inhibitors [2,3]. Pravastatin was likely to be safe when coadministered with ritonavir/saquinavir because, instead of an increase, we observed a 50% decrease in pravastatin area under the concentration–time curve (AUC). Although we also showed that pravastatin did not alter NFV pharmacokinetics, we did not examine the effect of NFV on pravastatin pharmacokinetics. More recently, we have demonstrated that a non-nucleoside reverse transcriptase inhibitor efavirenz, which is a CYP3A4 inducer, also reduced the plasma exposure of pravastatin [4].
The mechanism by which these drugs reduce plasma exposure to pravastatin is unknown, but this drug–drug interaction is of concern because a reduction in pravastatin plasma concentration may adversely affect the drug's ability to lower serum cholesterol effectively. NFV is one of the few PI drugs in clinical use that is not usually combined with ritonavir, but NFV has a similar effect on the CYP enzymes as ritonavir in that it is an inhibitor of CYP3A4 but an inducer of other CYP isoforms. Pravastatin metabolism is complex, utilizing both oxidative and conjugative enzymes for elimination, but CYP3A4 is not a significant enzyme in its metabolism. This study examines the hypothesis that NFV would have a similar effect on pravastatin pharmacokinetics as ritonavir/saquinavir.
Methods
The AIDS Clinical Trials Group (ACTG) study A5108 was a phase I, open-label, multiple-dose, pharmacokinetic drug interaction study. The primary objectives were to examine the effect of efavirenz on the pharmacokinetics of pravastatin, atorvastatin, and simvastatin and the effect of NFV on the pharmacokinetics of pravastatin. The efavirenz–statin interactions were recently published [4]. The data presented here address the effect of NFVon the pharmacokinetics of pravastatin. At the time of this study design, NFV was the most commonly prescribed PI in antiretroviral-naive patients.
Subjects
Healthy HIV-seronegative volunteers were recruited. The planned sample size was 14 subjects. Subjects who did not complete both pharmacokinetics evaluations were replaced. Subjects were accrued to the NFV arm from August through December 2001.
Study design
Subjects self-administered pravastatin 40 mg daily in the morning for the first 3 days and on the fourth day pravastatin was administered under observation. Blood samples were obtained before drug administration as well as 0.5, 1, 2, 3, 4, 6, 8, 12, and 24 h after administration, for pravastatin pharmacokinetics. On days 4 through 12, subjects took NFV 1250 mg twice daily with meals. On days 13 through 15, subjects continued NFV and restarted pravastatin with the morning dose of NFV. On day 16, pravastatin and NFV doses were administered under observation and samples were collected over 24 h for pravastatin pharmacokinetics. Fasting serum total cholesterol, triglycerides, and high density lipoprotein concentrations were measured at baseline and on days 3, 13, and 16 using standard enzymatic assays. Low density lipoprotein (LDL) was calculated using the Friedewald equation. Adherence to study medications was measured using pill counts and questionnaires.
The human subjects committees of each participating institution and the Division of AIDS, National Institute of Allergy and Infectious Diseases, approved this study and informed consent was obtained from all subjects.
Pravastatin assay
Samples for pravastatin plasma concentrations were analyzed by Advion Biosciences Inc. (Ithaca, New York, USA) as previously published [2,4].
Statistical analyses
The primary endpoint was the pravastatin AUC from 0 to 24 h before and after coadministration of NFV. Values for AUC were estimated according to the linear trapezoidal rule [5] implemented using a macro written in SAS version 8.2 (SAS Institute, Cary, North Carolina, USA). There was no extrapolation beyond the dosing interval. The maximum plasma concentration (Cmax), defined as the maximum concentration observed throughout the dosing interval, was also analyzed statistically. If both the 0 and 24 h concentrations or if both study day samples were unavailable for a given subject, pharmacokinetics parameters were not calculated. The Wilcoxon signed rank test [6], applied to within-subject differences in AUC and in Cmax values, was used to test the null hypothesis of no difference in pravastatin exposure before initiation of NFV versus after dosing to steady state. Values of Cmax were of interest because high plasma concentrations of statins may be associated with toxicity [7]. Pravastatin exposure when taken with NFV relative to when taken alone, median within-subject differences, and 90% confidence intervals (CI) around geometric mean ratios are reported. The last are recommended by the US Food and Drug Administration to evaluate bioequivalence and drug interactions [8].
Results
The study enrolled 18 subjects and three discontinued for protocol-defined toxicities: one had grade 2 bilirubin elevation owing to previously undiagnosed Gilbert's disease, one had grade 2 rash, and one had grade 2 creatine kinase elevation. A fourth subject was non-compliant and was discontinued from the study, leaving 14 subjects for whom pharmacokinetics data were available on both study days. Among the 14 subjects, two had grade 2 gastrointestinal complaints, one had grade 3 alanine aminotransferase and grade 2 aspartate aminotransferase on day 16, one had grade 2 fasting LDL elevation on day 13, and one had grade 2 skin eruptions on day 5 deemed unrelated to study medications. The population characteristics were a median age of 29 years, 50% women,79% white, 7% Latino, 7% African-American, and 7% Asian/Pacific Islanders.
Plots of time-specific geometric mean concentrations of pravastatin with and without NFV are shown in Fig. 1. Median pravastatin AUC values on days 3 and 16 were 86.5 and 46.8 ng·h/ml, respectively (Table 1). The P value indicated a high level of statistical significance for this difference. The median within-subject percentage change was a decrease of 46.5%, and the 90% CI around the geometric mean ratio was 0.46–0.65. Pravastatin Cmax values were also lower when pravastatin was administered with NFV. Median Cmax values were 27.9 and 12.4 ng/ml for days 3 and 16, respectively, and the median within-subject decrease was 40.1% (Table 1).
The median within-subject change in LDL, from baseline to day 13 (after 9 days of NFV administration), was an increase of 105 mg/l (mean, 144; 95% CI, 65–223). This change was significantly different from zero (P < 0.001,Wilcoxon signed rank test). Median (mean) changes after 3 days of pravastatin administration were –200 mg/l (mean, –195) from day 0 to day 3, and –155 mg/l (mean, –167) from day 13 to day 16, for a median difference in within-subject response to pravastatin of 28 mg/l (P = 0.436, Wilcoxon signed rank). The percentage change in LDL during the two periods was also calculated because the baseline LDL was increased by NFV. After 3 days of pravastatin administration, the median changes were –19.7% (mean, –19.8) from day 0 to day 3, and –11.4% (mean, –14.2) from day 13 to day 16, for a median difference in within-subject response to pravastatin of 6.7% (mean, 5.5). This difference was not statistically significant (P = 0.104, Wilcoxon signed rank test).
Discussion
The precise mechanism of HIV-associated dyslipidemia remains elusive [9]. Whether the dyslipidemia is a consequence of HIV itself, its resultant inflammation, or the adverse effects of medications, the fact remains that dyslipidemia is a common finding in HIV-infected individuals that warrants therapy. Interestingly, even in this study, the short-course administration of nelfinavir in healthy HIV-seronegative subjects was associated with a 105 mg/l median increase in LDL.
Pravastatin has become the preferred statin because of its lack of significant metabolism by P4503A4 and results from studies suggesting that pravastatin is safe and tolerable in patients taking potent antiretroviral therapy [10]. In our previous study, we demonstrated that ritonavir/saquinavir decreased the pravastatin median AUC by 50% [2]. In this study, NFV administration to steady state reduced the exposure to pravastatin by a median of 46.5%. Similarly, we have also demonstrated that efavirenz reduces the AUC of pravastatin [4].This reduction in exposure may compromise the effectiveness of pravastatin in patients taking certain PI drugs or efavirenz. Although our study was not adequately powered nor designed to evaluate pravastatin's effectiveness in lowering LDL, we did note a trend suggesting that its effectiveness was reduced.
The mechanism by which pravastatin concentrations are reduced is not known. The metabolism of pravastatin is complex. Induction of non-CYP3A4 oxidation or glucuronidation may result in more rapid clearance of pravastatin. In addition, hepatic transporter OATP1B1 may participate in increased drug elimination [11–13]. Rifampin, which induces both CYP isoforms as well as some transporters, reduced pravastatin exposure by a mean of 30% without affecting Cmax [14]. However, the CYP3A4 inhibitors itraconazole and mibefradil had no significant effect on pravastatin AUC [15]. Gemfibrozil as well as ciclosporin have been shown to increase pravastatin exposure during concomitant administration, pointing to probable involvement of hepatic transporters in this drug–drug interaction [16,17]. Regardless of the mechanism, the implication is that effectiveness of pravastatin may be reduced.
Clinical studies of pravastatin for the treatment of HIV-associated dyslipidemia have shown mixed results. For example, in a randomized trial of pravastatin versus fenofibrate for combined HIV-associated dyslipidemia, only 36% of subjects receiving 40 mg pravastatin daily met the LDL goal (median 20% decrease) and 18% met the triglyceride goal (median 13% decrease) by week 12 [18]. In contrast, in a randomized, open-label study comparing lipid-lowering therapy (pravastatin or bezafibrate) with a switch from PI drug to non-nucleoside reverse transcriptase inhibitors, Calza and colleagues [19] reported reductions in total cholesterol, LDL, and triglycerides of 45.8%, 39.5%, and 41.2%, respectively, after 20 mg pravastatin daily for 12 months. Interestingly, 55% of subjects receiving pravastatin had normal total cholesterol at 12 months. Benesic and colleagues [20] reported results for patients treated with pravastatin or fluvastatin. In 13 pravastatin-treated subjects (11 taking 10 mg pravastatin), a decrease in total cholesterol levels (from 7.12 to 6.29 mmol/l) after 12 weeks of therapy was reported. The reduction of LDL level was only 14.4% in the pravastatin group, without a significant reduction in triglycerides. None of these studies was specifically analyzed by the PI used to determine whether responses varied with specific PI drugs. It is also possible that dosing differences, adherence, or other factors may account for variations in efficacy reported.
In summary, pravastatin remains the statin of choice in HIV-infected persons taking antiretroviral therapy, given its safety profile compared with simvastatin and atorvastatin. The observed near 50% reduction in the pravastatin median AUC and a trend toward less reduction in LDL when coadministered with NFV suggest that higher doses of pravastatin may need to be prescribed to achieve optimal lipid-lowering activity. It remains unclear what the optimal dose of pravastatin is to achieve maximal lipid-lowering activity safely in HIV-infected individuals taking antiretroviral therapy. It is also possible that greater improvements in lipid levels may be observed if pravastatin doses are adjusted in the setting of agents that are known to induce reductions in concentrations. Further studies exploring the safety, tolerability, and efficacy of higher doses of pravastatin are warranted.
Acknowledgements
The ACTG A5108 team would like to thank the volunteers for participating in this study. Special thanks to F. Aweeka, M. Becker, W. J. Burning, R. Christensen, R. DiFrancesco, E. Ferguson, W. K. Henry, H. Meyers, S. I. Owens, M. Royal, J. Staggers, R. Strada, S. Valle, and, M. J. Werder for their invaluable assistance.
Appendix
Participating ACTG A5108 NFV-pravastatin investigators and sites: J. Norris, S. Valle (Stanford University); T. Powell, D. Daria (University of Cincinnati); and J. Reid, R. Reichman (University of Rochester Medical Center).
Footnotes
Sponsorship: This study was supported by the National Institute of Allergy and Infectious Diseases: AI-38858 to the AIDS Clinical Trials Group, AI-25897 to the University of Cincinnati, AI-27666 to Stanford University, AI-27658 to the University of Rochester Medical Center, AI-27665 to New York University, AI-32770 to the University of Colorado Health Sciences Center, and AI-38855 to the SDAC/Harvard School of Public Health. Additional support provided by Stanford University GCRC grant M01-RR00070 and University of Rochester Medical Center GCRC grant 5-M01-RR0044. Funded in part by Bristol-Myers Squibb Inc. and Pfizer Pharmaceutical.
Note: The results in this study were presented in part at the Second International AIDS Society Conference on HIV Pathogenesis and Treatment. Paris, July 2003.


Searching
问题描述 :
"You know what?" Angel said, "There is a love-letter from me embeded on the lawn. And if you can find it, it’s for you~"
"How can I find it on such a big lawn?"
"I will show you a hint: start from that tree which is in center of this lawn, and run directly to (X,Y) point. Please memorize the distance you’v passed. Then turn left with a angle A degree, and go ahead for k times of the length you’v passed in the first step. k is a real number from 0 to 1. When you arrive, repeat to turn left, and run for k times as far as the length of the last step. After many many times, you will reach a place, where I embed my letter…"
Of cause, Gardon wouldn’t follow her hint simply. He just run there directly. Can you do it?
"How can I find it on such a big lawn?"
"I will show you a hint: start from that tree which is in center of this lawn, and run directly to (X,Y) point. Please memorize the distance you’v passed. Then turn left with a angle A degree, and go ahead for k times of the length you’v passed in the first step. k is a real number from 0 to 1. When you arrive, repeat to turn left, and run for k times as far as the length of the last step. After many many times, you will reach a place, where I embed my letter…"
Of cause, Gardon wouldn’t follow her hint simply. He just run there directly. Can you do it?
输入:
Input have serveral test cases. Each cases have for real number: X,Y,A,k
输出:
For each case, print the place where the treasure is embed.
样例输入:
1 0 90 0.5 1 0 90 0 1 0 0 0.5
样例输出:
(0.800,0.400) (1.000,0.000) (2.000,0.000)
题目主要是向量的运算，用复数类complex比较方便，头文件为#include
向量（x+yi)向左转a角度，大小为原来的k倍，得到向量（x’+y’i)转换公式：
x’=x*cos(a)-y*sin(a);
y’=y*cos(a)+x*sin(a);
=>(x’+y’i)=k*(cos(a)+sin(a)i)*(x+yi);
可以看出成等比数列；
题目就是求它的和的极限。
既:（X,Yi）=（x+yi)/((1,0)-k*(cos(a)+sin（a)i));
#include<cstring> #include<complex> #include<cmath> #define pi acos(-1.0) using namespace std; typedef complex<double>Comp; double x,y,A,k; int main() { int i,j; while(scanf("%lf%lf%lf%lf",&x,&y,&A,&k)!=EOF) { A=A*pi/180.0; Comp a(x,y); Comp b(1-k*cos(A),-k*sin(A)); Comp c=a/b; printf("(%.3lf,%.3lf)\n",c.real(),c.imag()); } return 0; }
(adsbygoogle = window.adsbygoogle || []).push({});
恩 有道理 哈哈~~
恩 有道理 哈哈~~
恩 有道理 哈哈~~
恩 有道理 哈哈~~
恩 有道理 哈哈~~
恩 有道理 哈哈~~
恩 有道理 哈哈~~
恩 有道理 哈哈~~
这张页面太松散拉，重新编辑一下，弄紧凑一点。
已修改。一些字符在编辑的时候转义了
.net中char类型不是两个字节么
请问printAllCombination的时间复杂度怎么分析呢？
给力的文章，例子也非常好
Often We don’t set up on weblogs, but I would like to condition that this established up really forced me individually to do this! considerably outstanding publish
不太懂呀，乡亲们。原理知道代码不会
没有对题目进行一番分析，真是美中不足啊
很给力啊，学习了
这一题的代码这样提交时错误的~少考虑了很多情况
程序员会算法，等于一个古惑仔带了zhi抢啊
神奇的网站


Bounded by the Nilgiris hills on the East and the Arabian Sea on the west, the district of Malappuram literally the land atop the hills, is remarkable for its unique natural beauty. Perched among the undulating hills and the meandering rivers that flow to reach the coconut-fringed seacoast, the land conceals a unique and eventful history.
The hill country also contributed much to the cultural artistic traditions of the state. The mosques and temples of the land are known for their spectacular festivals. The land of great poets and writers, political and religious leaders, the district has carved a unique place of its own in the history of Kerala Home to the khilafath movement and the mappila revolts, which questioned the British authority in India, Malappuram was the military headquarters of the zamorins of Kozhikode since ancient times. Malappuram District was formed on 16th of June 1969 with the Nilgiris of Tamilnadu in the east, Arabian sea in the west, Kozhikode and Wayanad Districts in the north and Palakkad and Thrissur District in the south. The District has a geographical area of 3550 sq. kms, which is 9.13% of total area of the state and ranks 3rd in the state.


Fixing our broken system won’t happen overnight so we need your ongoing support.
We need recurring, monthly contributions to Mayday.us as the cornerstone of our funding. Ongoing contributions are critical for hiring organizers in key districts, supporting volunteers, and complementary digital advertising.


Need help getting started? We’re here to make sure setting up your wallet and getting up and running with Merit is as easy
as possible!
Access the Setup Tracker in the left side navigation menu at any time to track your overall progress and
learn about all there is to do in the Merit app.
Look for the progress icon throughout the app. Clicking the icon will display explanations for important features throughout
the app.
Already an expert? Navigate to the Setup Tracker and disable the feature.


GETPID
Section: Linux Programmer's Manual (2)
Updated: 2008-09-23
Index
Return to Main Contents
NAME
getpid, getppid - get process identification
SYNOPSIS
#include <sys/types.h>
#include <unistd.h>
pid_t getpid(void);
pid_t getppid(void);
DESCRIPTION
getpid()
returns the process ID of the calling process.
(This is often used by
routines that generate unique temporary filenames.)
getppid()
returns the process ID of the parent of the calling process.
ERRORS
These functions are always successful.
CONFORMING TO
POSIX.1-2001, 4.3BSD, SVr4.
NOTES
Since glibc version 2.3.4,
the glibc wrapper function for
getpid()
caches PIDs,
so as to avoid additional system calls when a process calls
getpid()
repeatedly.
Normally this caching is invisible,
but its correct operation relies on support in the wrapper functions for
fork(2),
vfork(2),
and
clone(2):
if an application bypasses the glibc wrappers for these system calls by using
syscall(2),
then a call to
getpid()
in the child will return the wrong value
(to be precise: it will return the PID of the parent process).
See also
clone(2)
for discussion of a case where
getpid()
may return the wrong value even when invoking
clone(2)
via the glibc wrapper function.
SEE ALSO
clone(2),
fork(2),
kill(2),
exec(3),
mkstemp(3),
tempnam(3),
tmpfile(3),
tmpnam(3),
credentials(7)
Index
- NAME
-
- SYNOPSIS
-
- DESCRIPTION
-
- ERRORS
-
- CONFORMING TO
-
- NOTES
-
- SEE ALSO
-
This document was created by
man2html,
using the manual pages.
Time: 02:54:51 GMT, September 18, 2014


 Keener pangs,{% endraw %}
{% raw %}deeper joys, more singular vicissitudes, few have{% endraw %}
{% raw %}been led in God's providence to experience. As I{% endraw %}
{% raw %}look back on it through the vista of more than{% endraw %}
{% raw %}eighty years, and scene after scene rises before me,.{% endraw %}
{% raw %}an ever fresh wonder fills my mind. I delight to{% endraw %}
{% raw %}recall it. I dwell on it as did the Jews on the mar¬{% endraw %}
{% raw %}vellous history of their rescue from the bondage of{% endraw %}
{% raw %}Egypt. Time has touched with its mellowing fin¬{% endraw %}
{% raw %}gers its sterner features. The sufferings of the past{% endraw %}
{% raw %}are now like a dream, and the enduring lessons left{% endraw %}
{% raw %}behind, make me to praise God that my soul has been{% endraw %}
{% raw %}B{% endraw %}


Register
Use the form below to book your tickets. This year, you must order a ticket for the Saturday evening conference meal separately. Due to logistical problems encountered last year, we've limited the number of meal tickets to 150 place this year. It's a popular event, so book a place while you can.
To register your interest in attending as a sponsored Trans*Code and/or Django Girls participant please use this form and we'll be in touch.
For the unwaged, university students or those on a low income, please contact us directly for ways in which we can support your attendance. Such help, if offered, is entirely at the discretion of the PyCon UK organising committee.
(If you don't see a form above, please try with a different browser.)


Image Decoder
How to use:
Copy image string from aws S3
Paste image string into text box (this takes some time)
Click decode (this takes some time)
Image will appear
Decode