Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3347236
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T01:23:52+00:00 2026-05-18T01:23:52+00:00

This is a follow-up to this question . I am working on a low

  • 0

This is a follow-up to this question.

I am working on a low level C app where I have to draw text. I have decided to store the font I want to use as an array (black and white, each char 128×256, perhaps), then I’d downscale it to the sizes I need with some algorithm (as grayscale, so I can have some crude font smoothing).

Note: this is a toy project, please disregard stuff like doing calculations at runtime or not.

Question is, which algorithm?

I looked up 2xSaI, but it’s rather complicated. I’d like something I can read the description for and work out the code myself (I am a beginner and have been coding in C/C++ for just under a year).

Suggestions, anyone?

Thanks for your time!

Edit: Please note, the input is B&W, the output should be smoothed grayscale

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T01:23:52+00:00Added an answer on May 18, 2026 at 1:23 am

    Figure out the rectangle in the source image that will correspond to a destination pixel. For example if your source image is 50×100 and your destination is 20×40, the upper left pixel in the destination corresponds to the rectangle from (0,0) to (2.2,2.2) in the source image. Now, do an area-average over those pixels:

    • Area is 2.2 * 2.2 = 4.84. You’ll scale the result by 1/4.84.
    • Pixels at (0,0), (0,1), (1,0), and (1,1) each weigh in at 1 unit.
    • Pixels at (0,2), (1,2), (2,0), and (2,1) each weigh in at 0.2 unit (because the rectangle only covers 20% of them).
    • The pixel at (2,2) weighs in at 0.04 (because the rectangle only covers 4% of it).
    • The total weight is of course 4*1 + 4*0.2 + 0.04 = 4.84.

    This one was easy because you started with source and destination pixels lined up evenly at the edge of the image. In general, you’ll have partial coverage at all 4 sides/4 corners of the sliding rectangle.

    Don’t bother with algorithms other than area-averaging for downscaling. Most of them are plain wrong (they result in horrible aliasing, at least with a factor smaller than 1/2) and the ones that aren’t plain wrong are a good bit more painful to implement and probably won’t give you better results.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is a follow-on question to the How do you use ssh in a
This is a follow up question . So, Java store's integers in two's-complements and
PHP mysql database I have created a follow on question to this one here
this is a follow up on my question on paypal integration. I'm working ona
This is a follow up question from here . Where I want do go
In direct follow-up to this previous question , how can I pull the text
(there is a follow up to this question here ) I am working on
This is a follow-up question from here . The code is working great, it
Update: Check out this follow-up question: Gem Update on Windows - is it broken?
This is a follow on question to How do I delete 1 file from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.