?
Solved

How to shrink image in high quaulity?

Posted on 2003-02-25
2
Medium Priority
?
591 Views
Last Modified: 2013-11-20
I want to shrink monochrome images in high quality. I have tried to use StretchBlt and set stretch mode to HALFTONE. The effect is very good but the HALFTONE mode doesn't support WIN9x. And I also tried to apply convolution algorithm to smooth images before shrinking, when the shrinking rate is not very high, say 0.4, the effect is acceptable, but if the rate is high, less than 0.3, the effect is bad. To improve the shrinking quality, I have convert the monochrome images from 1 bit to 8 bit format. Is there anyone know how do I shrink images in high quality?
0
Comment
Question by:PearlChen
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 8

Accepted Solution

by:
Answers2000 earned 200 total points
ID: 8024895
Convert them to gray scale when scaling down.

Algorithm is:-

For every pixel in destination bitmap
  Work out a square/rectangle of pixels in source bitmap
  X = The average color (black = 0, white=255) of pixels in this source square. Simply loop over this square, add up a running total, and at end divide by how many pixels in this square.
  Set destination pixel color to RGB(X,X,X)


Example:

Assume scaling down by half: 2X2 square in monochrome, has 0, 1, 2 or 3 pixels set to white. If it's  This can means destination pixel is RGB(0,0,0), RGB(64,64,64), RGB(128,128,128),RGB(192,192,192) or RGB(255,255,255)

If you scale down by 1/3 or more, you're going to start losing data, but will work. You probably need to go 24 bit color at this point to get it to look really good.
0
 

Author Comment

by:PearlChen
ID: 8031827
Thank you very much, anwser2000. I have tried your algorithm in my program and the result turned out to be what I exactly want. I converted the bilevel bitmaps into gray scale bitmaps(8 bits per pixel), then selected a pallete created by myself which including 256 steps of gray scale.

I have thought my desired result must be gained through some complicated algorithm. I didn't expect it is so easy. The truth is always simple.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli‚Ķ
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question