Class Util
Inheritance
System.Object
Util
Syntax
Methods
BytesFromBitDepth(Int32)
Returns the number of bytes needed to store a single pixel of the
specified bit depth.
Declaration
public static int BytesFromBitDepth(int depth)
Parameters
Type |
Name |
Description |
System.Int32 |
depth |
|
Returns
Type |
Description |
System.Int32 |
|
BytesPerRow(Size, Int32)
Calculates the number of bytes required to store a row of an image
with the specified bit depth.
Declaration
public static int BytesPerRow(Size size, int bitDepth)
Parameters
Type |
Name |
Description |
Size |
size |
The size of the image in pixels.
|
System.Int32 |
bitDepth |
The bit depth of the image.
|
Returns
Type |
Description |
System.Int32 |
The number of bytes needed to store a row of the image.
|
CheckBufferBounds(Byte[], Int32, Int32)
Verify that the offset and count will remain within the bounds of the
buffer.
Declaration
public static bool CheckBufferBounds(byte[] data, int offset, int count)
Parameters
Type |
Name |
Description |
System.Byte[] |
data |
|
System.Int32 |
offset |
|
System.Int32 |
count |
|
Returns
Type |
Description |
System.Boolean |
True if in bounds, false if out of bounds.
|
CheckByteArrayLength(Int64)
Declaration
public static void CheckByteArrayLength(long length)
Parameters
Type |
Name |
Description |
System.Int64 |
length |
|
DebugMessage(Stream, String, Object[])
Writes a message to the debug console, indicating the current position
in the stream in both decimal and hexadecimal formats.
Declaration
[Conditional("DEBUG")]
public static void DebugMessage(Stream stream, string message, params object[] args)
Parameters
Type |
Name |
Description |
System.IO.Stream |
stream |
|
System.String |
message |
|
System.Object[] |
args |
|
Fill(Byte[], Int32, Int32, Byte)
Fills a buffer with a byte value.
Declaration
public static void Fill(byte[] ptr, int start, int end, byte value)
Parameters
Type |
Name |
Description |
System.Byte[] |
ptr |
|
System.Int32 |
start |
|
System.Int32 |
end |
|
System.Byte |
value |
|
GetPadding(Int32, Int32)
Get number of bytes required to pad to the specified multiple.
Declaration
public static int GetPadding(int length, int padMultiple)
Parameters
Type |
Name |
Description |
System.Int32 |
length |
|
System.Int32 |
padMultiple |
|
Returns
Type |
Description |
System.Int32 |
|
IntersectWith(Rectangle, Rectangle)
Declaration
public static Rectangle IntersectWith(this Rectangle thisRect, Rectangle rect)
Parameters
Returns
Invert(Byte[], Int32, Int32)
Declaration
public static void Invert(byte[] ptr, int ptrStart, int ptrEnd)
Parameters
Type |
Name |
Description |
System.Byte[] |
ptr |
|
System.Int32 |
ptrStart |
|
System.Int32 |
ptrEnd |
|
MinChannelCount(PsdColorMode)
Declaration
public static short MinChannelCount(this PsdColorMode colorMode)
Parameters
Returns
Type |
Description |
System.Int16 |
|
RoundUp(Int32, Int32)
Round the integer to a multiple.
Declaration
public static int RoundUp(int value, int multiple)
Parameters
Type |
Name |
Description |
System.Int32 |
value |
|
System.Int32 |
multiple |
|
Returns
Type |
Description |
System.Int32 |
|
SwapByteArray(Int32, Byte[], Int32, Int32)
Declaration
public static void SwapByteArray(int bitDepth, byte[] byteArray, int startIdx, int count)
Parameters
Type |
Name |
Description |
System.Int32 |
bitDepth |
|
System.Byte[] |
byteArray |
|
System.Int32 |
startIdx |
|
System.Int32 |
count |
|
SwapByteArray2(Byte[], Int32, Int32)
Reverses the endianness of 2-byte words in a byte array.
Declaration
public static void SwapByteArray2(byte[] byteArray, int startIdx, int count)
Parameters
Type |
Name |
Description |
System.Byte[] |
byteArray |
Byte array containing the sequence on which to swap endianness
|
System.Int32 |
startIdx |
Byte index of the first word to swap
|
System.Int32 |
count |
Number of words to swap
|
SwapByteArray4(Byte[], Int32, Int32)
Reverses the endianness of 4-byte words in a byte array.
Declaration
public static void SwapByteArray4(byte[] byteArray, int startIdx, int count)
Parameters
Type |
Name |
Description |
System.Byte[] |
byteArray |
Byte array containing the sequence on which to swap endianness
|
System.Int32 |
startIdx |
Byte index of the first word to swap
|
System.Int32 |
count |
Number of words to swap
|
SwapBytes(Byte[], Int32, Int32)
Reverses the endianness of a word of arbitrary length.
Declaration
public static void SwapBytes(byte[] ptr, int start, int nLength)
Parameters
Type |
Name |
Description |
System.Byte[] |
ptr |
|
System.Int32 |
start |
|
System.Int32 |
nLength |
|
SwapBytes2(Byte[], Int32)
Reverses the endianness of a 2-byte word.
Declaration
public static void SwapBytes2(byte[] ptr, int start)
Parameters
Type |
Name |
Description |
System.Byte[] |
ptr |
|
System.Int32 |
start |
|
SwapBytes4(Byte[], Int32)
Reverses the endianness of a 4-byte word.
Declaration
public static void SwapBytes4(byte[] ptr, int start)
Parameters
Type |
Name |
Description |
System.Byte[] |
ptr |
|
System.Int32 |
start |
|
Did you find this page useful? Please give it a rating:
Thanks for rating this page!
What kind of problem would you like to report?
Thanks for letting us know! This page has been marked for review based on your feedback.
If you have time, you can provide more information to help us fix the problem faster.
Provide more information
You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:
You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:
You've told us there is information missing from this page. Please tell us more about what's missing:
You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:
You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:
You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:
You've told us this page has a problem. Please tell us more about what's wrong:
Thank you for helping to make the Unity documentation better!
Your feedback has been submitted as a ticket for our documentation team to review.
We are not able to reply to every ticket submitted.