Advertisement
Guest User

Untitled

a guest
Feb 25th, 2015
238
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None
  1. static grub_err_t
  2. scale_nn (struct grub_video_bitmap *dst, struct grub_video_bitmap *src)
  3. {
  4. grub_err_t err = verify_bitmaps(dst, src);
  5. if (err != GRUB_ERR_NONE)
  6. return err;
  7.  
  8. grub_uint8_t *ddata = dst->data;
  9. grub_uint8_t *sdata = src->data;
  10. unsigned dw = dst->mode_info.width;
  11. unsigned dh = dst->mode_info.height;
  12. unsigned sw = src->mode_info.width;
  13. unsigned sh = src->mode_info.height;
  14. unsigned dstride = dst->mode_info.pitch;
  15. unsigned sstride = src->mode_info.pitch;
  16. unsigned bytes_per_pixel = dst->mode_info.bytes_per_pixel;
  17. unsigned x_ratio = ((sw << 16) / dw) + 1;
  18. unsigned y_ratio = ((sh << 16) / dh) + 1;
  19. unsigned src_line, dst_line, src_pos, dst_pos, ratio, i, j, k;
  20.  
  21. for (i=0;i<dh;i++) {
  22. src_line = ((i*y_ratio)>>16)*sstride;
  23. dst_line = i*dstride;
  24. ratio = 0;
  25. for (j=0;j<dw;j++){
  26. src_pos = src_line+(ratio>>16)*bytes_per_pixel;
  27. dst_pos = dst_line+j*bytes_per_pixel;
  28. for (k=0;k<bytes_per_pixel;k++){
  29. ddata[dst_pos+k] = sdata[src_pos+k];
  30. }
  31. ratio+=x_ratio;
  32. }
  33. }
  34. return GRUB_ERR_NONE;
  35. }
Advertisement
RAW Paste Data Copied
Advertisement