Click here to Skip to main content
15,911,360 members
Articles / Desktop Programming / Win32
Article

Irregular or non rectangular shaped bitmap

Rate me:
Please Sign up or sign in to vote.
2.00/5 (8 votes)
4 Feb 2008CPOL2 min read 40.5K   466   11   7
Convert rectangular bitmap into non rectangular bitmap (.ppg)
Image 1

Introduction

So many times we feel need of non rectangular bitmap, bitmap which store only the required

portion of the picture leaving outside area. You just do it by defining the desired area and call

a function to store the picture inside the selected area. Then just by calling another function

to make a bitmap of stored pixels and use it anywhere. The pixels outside the selected area

in bitmap will not be visible in bitmap because it uses alpha value 0.

Detail

This application provides the capability to user to transform rectangular bitmap or picture to non
rectangular picture by clipping areas outside the boundaries. User can separate out the desired part and undesirable part of picture just by drawing polygon using mouse cursor.

Background

Whenever we store some image on secondary device we store the image in outbound rectangular area. In that case rectangular area which is not part of image has to be filled with some color and consumes unwanted memory. Instead if only the desired area of image is stored then it gives a lot of advantage in saving secondary memory. Loading and saving image will be more cpu intensive compared to rectangular bitmap but more space effective.

Points of Interest

This algorithm stores only the pixels color inside the polygon boundary and saves a lot of extra
space that was wasted by outside area. For example take case of a "cross" picture actually need only 10% part of total storage and wastes 90% of storage. So our algorithm will save 90% of space in this case.

How to use

Steps to perform.

1. Open normal bitmap.

2. Define outbound area polygon by free polygon/ bounded polygon.

3. Save irregular shaped bitmap as ppg picture.

4. Close current picture.

5. Open last saved ppg picture.

6. If more do steps 2 to 5.

7. Look at the size of original bitmap and ppg picture. Ya It does....

History

I would like to listen users review/comments on this article. It stores picture pixels in ARGB format, if further compression like jpeg or gif is provided it may prove better than them also.

Thanks

Vikas Maan, Tek

vikas.jpg

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior)
India India
Vikas Maan is a software developer for last 4 years working on windows platform with multiple programming languages mainly VC++, C#.net etc.

Comments and Discussions

 
QuestionConvert to bmp Pin
quincy67927-Sep-10 0:01
quincy67927-Sep-10 0:01 
QuestionRe: Convert to bmp Pin
Member 898179017-May-12 1:15
Member 898179017-May-12 1:15 
GeneralSource Code please Pin
akuppach10-May-10 9:47
akuppach10-May-10 9:47 
Questionhow are your scan lines defined in the dib? Pin
ed5233-Mar-10 13:29
ed5233-Mar-10 13:29 
Generalsource code Pin
ivi hermanto7-Mar-09 0:46
ivi hermanto7-Mar-09 0:46 
GeneralPixel buffers Pin
Ray Hayes23-Jan-08 23:49
Ray Hayes23-Jan-08 23:49 
GeneralRe: Pixel buffers Pin
vikas maan24-Jan-08 17:41
vikas maan24-Jan-08 17:41 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.