Solved

CBitmap manipulation

Posted on 1997-03-29
1
483 Views
Last Modified: 2013-11-20
Hello,

I am using MS devstudio 5 for NT 4.0 and I am having
problems handling simple bitmaps (256 colors). What should
be simple is taking me longer and longer to accomplish
as I get deeper and deeper in this mess of BITMAP, HBITMAP
BITMAPHEADERINFO and such...

What I am trying to do is simply to load a bitmap from file
and display it. And the reverse, storing it in a file.
(why is there no such thing as a CBitmap::WriteToFile()!!!)

Any how, this code shows the problem:
  *h= CreateDIBitmap(m_dcMem, &bmih, CBM_INIT, lpvBits, (BITMAPINFO*)lpmi, DIB_RGB_COLORS);

  CBitmap *px;
  DWORD tsize1;
  px= CBitmap::FromHandle(*h);
  tsize1= px->GetBitmapBits( (bmfh.bfSize - bmfh.bfOffBits), lpvBits );

h is a HBITMAP *. The problem is that tsize1 is only 67000
and NOT the expected (bmfh.bfSize - bmfh.bfOffBits) which
is more like 670000! What's wrong????

Is there a CBitmap toolkit or a derived class complete
with manipulation tools such a write/read and
copy to/from clipboard???? Can you provide references?
Is it free and does it work???

HELP... I am getting desperate!!!

Thanks.

Guy Thibault
gthibault@artefact.qc.ca

0
Comment
Question by:aquila
[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
1 Comment
 

Accepted Solution

by:
syed_dgreat earned 150 total points
ID: 1300725
Regarding the first question, it's a big relief that Windows 95 + NT now provides a function which does exactly what you want:-
HBITMAP hBitmap = (HBITMAP)::LoadImage(AfxGetInstanceHandle(),
"mybitmap.bmp", IMAGE_BITMAP, 0, 0, LR_CREATEDIBSECTION | LR_LOADFROMFILE);
And how to save the file is not very easy actually. You have
to manipulate BITMAPFILEHEADER bla bla bla... Let me know
if you are interested (email : sxs296@psu.edu). I cannot stay online for too long :(.

The last question :-
There's a free imaging OCX that I have found so far which
is quite excellent. It shows the copyright dialogbox during
startup though. The url of interest is
home.earthlink.net\~bananasoft

However, if you want your app to be really professional,
I suggest you to look for LeadTools (www.leadtools.com)

0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

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

Suggested Solutions

Title # Comments Views Activity
xyBalance chalenge 58 105
changeXy challenge 13 98
mapAB Challlenge 35 186
Windows shortcut location resolution on double click open 4 78
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.
In this post we will learn different types of Android Layout and some basics of an Android App.
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.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
Suggested Courses

752 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