Game Development Reference
In-Depth Information
}
}
return
baseList;
}
There're 2 overloading
cutBitmap()
methods that are also useful when subsetting a Bitmap
sheet.
//Subsets the source bitmap to frames with the specified size w x h,
//stores the result in a bitmap array.
//Parameters:
// source - the specified bitmap to be subset
// result - a bitmap array that stores the frames
// imgid - the image id of source
// rows - the number of rows
// cols - the number of cols
// w - the width of the frame
// h - the height of the frame
public static void
cutBitmap(Bitmap source,Bitmap [] result,
int
imgid,
int
rows,
int
cols,
int
w,
int
h){
for
(
int
i=0;i<rows;i++){
for
(
int
j=0;j<cols;j++){
result[imgid+i*cols+j]
= Bitmap.
createBitmap
(source, j*w, i*h, w, h);
}
}
}
//Subsets the source bitmap to frames with the specified size w x h,
//stores the result in a bitmap array.
//Parameters:
//
source - the specified bitmap to be subset
//
result - a bitmap array that stores the frames
//
imgid - the image id of source
//
px - offset x coordinate
//
py - offset y coordinate
//
rows - the number of rows
//
cols - the number of cols
//
w - the width of the frame
//
h - the height of the frame
Search WWH ::
Custom Search