Hi, what would be the best way to scale the size of actor faces?
This is the draw_face method:
def draw_face(face_name, face_index, x, y, enabled = true) bitmap = Cache.face(face_name) rect = Rect.new(face_index % 4 * 96, face_index / 4 * 96, 96, 96) contents.blt(x, y, bitmap, rect, enabled ? 255 : translucent_alpha) bitmap.dispose endNow Im clueles what to do, because the bitmap contains sets of faces.
Lets say I want to scale the drawn face by the factor 0.75, so it will be drawn with a size of 75 * 75 instead of 96 * 96.
I dont want that the source faceset file will be changed, it should be the same size as the default faceset size.
My idea was to resize the whole bitmap at first by the factor and after that
use something like this for the rect:
factor = 0.75new_size = factor * 96rect = Rect.new(face_index % 4 * new_size, face_index / 4 * new_size, new_size, new_size)But I cant do it because I dont know how to resize the bitmap.
*edit*
This is how my solution looks like:
def draw_face(face_name, face_index, x, y, enabled = true) f = 0.75 n = 96 * f source_bitmap = Cache.face(face_name) target_bitmap = Bitmap.new(source_bitmap.width * f, source_bitmap.height * f) target_bitmap.stretch_blt(target_bitmap.rect, source_bitmap, source_bitmap.rect) rect = Rect.new(face_index % 4 * n, face_index / 4 * n, n, n) contents.blt(x, y, target_bitmap, rect, enabled ? 255 : translucent_alpha) source_bitmap.dispose target_bitmap.dispose endIs it ok or do you have something better?
This is the draw_face method:
def draw_face(face_name, face_index, x, y, enabled = true) bitmap = Cache.face(face_name) rect = Rect.new(face_index % 4 * 96, face_index / 4 * 96, 96, 96) contents.blt(x, y, bitmap, rect, enabled ? 255 : translucent_alpha) bitmap.dispose endNow Im clueles what to do, because the bitmap contains sets of faces.
Lets say I want to scale the drawn face by the factor 0.75, so it will be drawn with a size of 75 * 75 instead of 96 * 96.
I dont want that the source faceset file will be changed, it should be the same size as the default faceset size.
My idea was to resize the whole bitmap at first by the factor and after that
use something like this for the rect:
factor = 0.75new_size = factor * 96rect = Rect.new(face_index % 4 * new_size, face_index / 4 * new_size, new_size, new_size)But I cant do it because I dont know how to resize the bitmap.
*edit*
This is how my solution looks like:
def draw_face(face_name, face_index, x, y, enabled = true) f = 0.75 n = 96 * f source_bitmap = Cache.face(face_name) target_bitmap = Bitmap.new(source_bitmap.width * f, source_bitmap.height * f) target_bitmap.stretch_blt(target_bitmap.rect, source_bitmap, source_bitmap.rect) rect = Rect.new(face_index % 4 * n, face_index / 4 * n, n, n) contents.blt(x, y, target_bitmap, rect, enabled ? 255 : translucent_alpha) source_bitmap.dispose target_bitmap.dispose endIs it ok or do you have something better?