Class ARGBType
- java.lang.Object
-
- net.imglib2.type.AbstractNativeType<ARGBType>
-
- net.imglib2.type.numeric.ARGBType
-
- All Implemented Interfaces:
NativeType<ARGBType>
,NumericType<ARGBType>
,Add<ARGBType>
,Div<ARGBType>
,Mul<ARGBType>
,MulFloatingPoint
,SetOne
,SetZero
,Sub<ARGBType>
,ValueEquals<ARGBType>
,Type<ARGBType>
public class ARGBType extends AbstractNativeType<ARGBType> implements NumericType<ARGBType>
Anative
NumericType
that encodes four channels at unsigned byte precision into one 32bit signed integer which is the format used in most display oriented image processing libraries such as AWT or ImageJ.ARGBType
implementsNumericType
as element-wise vector algebra.- Author:
- Stephan Preibisch, Stephan Saalfeld
-
-
Field Summary
Fields Modifier and Type Field Description protected IntAccess
dataAccess
protected NativeImg<?,? extends IntAccess>
img
-
Fields inherited from class net.imglib2.type.AbstractNativeType
i
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(ARGBType c)
static int
alpha(int value)
static int
blue(int value)
ARGBType
copy()
NativeImg<ARGBType,? extends IntAccess>
createSuitableNativeImg(NativeImgFactory<ARGBType> storageFactory, long[] dim)
TheNativeType
creates theNativeImg
used for storing image data; based on the given storage strategy and its size.ARGBType
createVariable()
Creates a newType
variable which can only store one value.void
div(ARGBType c)
ARGBType
duplicateTypeOnSameNativeImg()
Creates a newNativeType
which stores in the same physical array.int
get()
Fraction
getEntitiesPerPixel()
Get the number of entities in the storage array required to store one pixel value.static int
green(int value)
void
mul(double c)
void
mul(float c)
void
mul(ARGBType c)
static int
red(int value)
static int
rgba(double r, double g, double b, double a)
static int
rgba(float r, float g, float b, float a)
static int
rgba(int r, int g, int b, int a)
void
set(int f)
void
set(ARGBType c)
Sets the value of anotherType
.void
setOne()
void
setZero()
void
sub(ARGBType c)
java.lang.String
toString()
void
updateContainer(java.lang.Object c)
This method is used by an accessor (e.g., aCursor
) to request an update of the current data array.boolean
valueEquals(ARGBType t)
-
Methods inherited from class net.imglib2.type.AbstractNativeType
decIndex, decIndex, getIndex, incIndex, incIndex, updateIndex
-
-
-
-
Method Detail
-
createSuitableNativeImg
public NativeImg<ARGBType,? extends IntAccess> createSuitableNativeImg(NativeImgFactory<ARGBType> storageFactory, long[] dim)
Description copied from interface:NativeType
TheNativeType
creates theNativeImg
used for storing image data; based on the given storage strategy and its size. It basically only decides here which BasicType it uses (float, int, byte, bit, ...) and how many entities per pixel it needs (e.g. 2 floats per pixel for a complex number). This enables the separation of containers and the basic types.- Specified by:
createSuitableNativeImg
in interfaceNativeType<ARGBType>
- Parameters:
storageFactory
- which storage strategy is useddim
- the dimensions- Returns:
- the instantiated
NativeImg
where only theType
knows the BasicType it contains.
-
updateContainer
public void updateContainer(java.lang.Object c)
Description copied from interface:NativeType
This method is used by an accessor (e.g., aCursor
) to request an update of the current data array.As an example consider a
CellCursor
moving on aCellImg
. The cursor maintains aNativeType
which provides access to the image data. When the cursor moves from one cell to the next, the underlying data array of theNativeType
must be switched to the data array of the new cell.To achieve this, the
CellCursor
callsupdateContainer()
with itself as the argument.updateContainer()
in turn will callNativeImg.update(Object)
on it's container, passing along the reference to the cursor. In this example, the container would be aCellImg
. While theNativeType
does not know about the type of the cursor, the container does.CellImg
knows that it is passed aCellCursor
instance, which can be used to figure out the current cell and the underlying data array, which is then returned to theNativeType
.The idea behind this concept is maybe not obvious. The
NativeType
knows which basic type is used (float, int, byte, ...). However, it does not know how the data is stored (ArrayImg
,CellImg
, ...). This prevents the need for multiple implementations ofNativeType
.- Specified by:
updateContainer
in interfaceNativeType<ARGBType>
- Parameters:
c
- reference to an accessor which can be passed on to the container (which will know what to do with it).
-
duplicateTypeOnSameNativeImg
public ARGBType duplicateTypeOnSameNativeImg()
Description copied from interface:NativeType
Creates a newNativeType
which stores in the same physical array. This is only used internally.- Specified by:
duplicateTypeOnSameNativeImg
in interfaceNativeType<ARGBType>
- Returns:
- a new
NativeType
instance working on the sameNativeImg
-
rgba
public static final int rgba(int r, int g, int b, int a)
-
rgba
public static final int rgba(float r, float g, float b, float a)
-
rgba
public static final int rgba(double r, double g, double b, double a)
-
red
public static final int red(int value)
-
green
public static final int green(int value)
-
blue
public static final int blue(int value)
-
alpha
public static final int alpha(int value)
-
get
public int get()
-
set
public void set(int f)
-
mul
public void mul(float c)
- Specified by:
mul
in interfaceMulFloatingPoint
-
mul
public void mul(double c)
- Specified by:
mul
in interfaceMulFloatingPoint
-
set
public void set(ARGBType c)
Description copied from interface:Type
Sets the value of anotherType
.
-
createVariable
public ARGBType createVariable()
Description copied from interface:Type
Creates a newType
variable which can only store one value.- Specified by:
createVariable
in interfaceType<ARGBType>
- Returns:
- a new
Type
variable
-
toString
public java.lang.String toString()
- Specified by:
toString
in classAbstractNativeType<ARGBType>
-
getEntitiesPerPixel
public Fraction getEntitiesPerPixel()
Description copied from interface:NativeType
Get the number of entities in the storage array required to store one pixel value. A pixel value may be spread over several or less than one entity. For example, a complex number may require 2 entries of a float[] array to store one pixel. Or a 12-bit type might need 12/64th entries of a long[] array.- Specified by:
getEntitiesPerPixel
in interfaceNativeType<ARGBType>
- Returns:
- the number of storage type entities required to store one pixel value.
-
valueEquals
public boolean valueEquals(ARGBType t)
- Specified by:
valueEquals
in interfaceValueEquals<ARGBType>
-
-