Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static grub_err_t
- scale_nn (struct grub_video_bitmap *dst, struct grub_video_bitmap *src)
- {
- grub_err_t err = verify_bitmaps(dst, src);
- if (err != GRUB_ERR_NONE)
- return err;
- grub_uint8_t *ddata = dst->data;
- grub_uint8_t *sdata = src->data;
- unsigned dw = dst->mode_info.width;
- unsigned dh = dst->mode_info.height;
- unsigned sw = src->mode_info.width;
- unsigned sh = src->mode_info.height;
- unsigned dstride = dst->mode_info.pitch;
- unsigned sstride = src->mode_info.pitch;
- unsigned bytes_per_pixel = dst->mode_info.bytes_per_pixel;
- unsigned x_ratio = ((sw << 16) / dw) + 1;
- unsigned y_ratio = ((sh << 16) / dh) + 1;
- unsigned src_line, dst_line, src_pos, dst_pos, ratio, i, j, k;
- for (i=0;i<dh;i++) {
- src_line = ((i*y_ratio)>>16)*sstride;
- dst_line = i*dstride;
- ratio = 0;
- for (j=0;j<dw;j++){
- src_pos = src_line+(ratio>>16)*bytes_per_pixel;
- dst_pos = dst_line+j*bytes_per_pixel;
- for (k=0;k<bytes_per_pixel;k++){
- ddata[dst_pos+k] = sdata[src_pos+k];
- }
- ratio+=x_ratio;
- }
- }
- return GRUB_ERR_NONE;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement