Convert PNG file to Bitmap without a DC?

I'd like to store images resources as PNGs due to the compression over 
bitmps.   To load such a resource and get it converted to a bitmap for the 
eventual Blit to my screen DC, I basically want the equivalent of 
LoadBitmap.  Better yet, I was thinking I would create a CBitmap derived 
class "CPNGImage" that would have a "LoadPNGResource" method much like 
CBitmap's LoadBitmap method. So far so good.

The stumbling block for me at this point is that the process of converting 
the PNG to a bitmap seems to require a DC compatible with my device.  This 
is neatly encapsulated/shown in CxImage's MakeBitmap function:

HBITMAP CxImage::MakeBitmap(HDC hdc)
{
 if ((!hdc) || (!hDib))  return NULL;
 HBITMAP bmp = CreateDIBitmap(hdc, (LPBITMAPINFOHEADER)hDib, CBM_INIT,
  GetBits(), (LPBITMAPINFO)hDib, DIB_RGB_COLORS);
 return bmp;
}

Contrast this to LoadBitmap, which does not require an HDC, but will still 
load a bitmap (16 or 24 bit color depth) from a resource and seems to 
convert it to a 32bit color depth just like what BitBlt to my screen DC 
wants.  How does LoadBitmap do this without access to my screen DC?  Or 
rather, how can I accomplish this same thing for my PNG resource without a 
screen DC?  Or is this not possible?

I have a feeling the answer has something to do with DIB vs. DDB, etc., but 
I just can't seem to figure out what is going on here.

Thanks for any help you can offer.

- Wil 


0
6/22/2006 5:10:05 PM
vc.mfc 33608 articles. 0 followers. Follow

1 Replies
877 Views

Similar Articles

[PageSpeed] 10

I think I've found an answer for my question here.  Using ::GetDC(0) returns 
the screen DC, and this DC can be used with CreateDIBitmap to create a 
screen compatible HBITMAP.

"Wil Stark" <wstark_NOSPAM_04@pobox.com> wrote in message 
news:1150995904.5833@newsreg.cos.agilent.com...
> I'd like to store images resources as PNGs due to the compression over 
> bitmps.   To load such a resource and get it converted to a bitmap for the 
> eventual Blit to my screen DC, I basically want the equivalent of 
> LoadBitmap.  Better yet, I was thinking I would create a CBitmap derived 
> class "CPNGImage" that would have a "LoadPNGResource" method much like 
> CBitmap's LoadBitmap method. So far so good.
>
> The stumbling block for me at this point is that the process of converting 
> the PNG to a bitmap seems to require a DC compatible with my device.  This 
> is neatly encapsulated/shown in CxImage's MakeBitmap function:
>
> HBITMAP CxImage::MakeBitmap(HDC hdc)
> {
> if ((!hdc) || (!hDib))  return NULL;
> HBITMAP bmp = CreateDIBitmap(hdc, (LPBITMAPINFOHEADER)hDib, CBM_INIT,
>  GetBits(), (LPBITMAPINFO)hDib, DIB_RGB_COLORS);
> return bmp;
> }
>
> Contrast this to LoadBitmap, which does not require an HDC, but will still 
> load a bitmap (16 or 24 bit color depth) from a resource and seems to 
> convert it to a 32bit color depth just like what BitBlt to my screen DC 
> wants.  How does LoadBitmap do this without access to my screen DC?  Or 
> rather, how can I accomplish this same thing for my PNG resource without a 
> screen DC?  Or is this not possible?
>
> I have a feeling the answer has something to do with DIB vs. DDB, etc., 
> but I just can't seem to figure out what is going on here.
>
> Thanks for any help you can offer.
>
> - Wil
> 


0
6/23/2006 8:30:37 PM
Reply:

Similar Artilces:

Can't get money 2002 to open money 98 backup file.
I keep getting an message saying either it isn't a money file or the file is corrupted. I did this over and over on diff. floppies. Still the same. It is on our biz laptop we backup money 98 to a floppy, then to our pc in the office we try to restore and no go. Any clues? Pretty much tried everything possible here. Thanx Ben In microsoft.public.money, Ben wrote: >I keep getting an message saying either it isn't a money >file or the file is corrupted. I did this over and over on >diff. floppies. Still the same. It is on our biz laptop we >backup money 98 to a flo...

Reading Publisher file after burning to CD
After a Publisher file is burned to a CD, error message says Publisher cannot find that file. ...

How to Convert UTC to localTIme(C# )
I have got the value of user account's lastlogon time. Its type is Int64. This value is stored as a large integer that represents the number of 100 nanosecond intervals since January 1, 1601 (UTC)(Refer to MSDN). I don't know how to convert this value to localTime. The following is my code. ################################################################ DirectoryEntry deUser = new DirectoryEntry(ldappath); DirectorySearcher src = new DirectorySearcher(deUser); src.Filter = "(&(objectClass=user)(SAMAccountName=" + accountNa...

Convert text to time value
I have a series of time values in a 'General' format. They are of the type: 184525 Which is 18:45:25 or 6:45:25 pm. A time which is am would be of the type: 12345 Which is 1:23:45 am. Is there a way to convert those 'General' values to an Excel serial so that I can figure out the difference between two times? I've seen a bunch of examples on the net, but none of those that I have found deal with this format that I can tell. Thanks. Hi try =--TEXT(A1,"00:00:00") -- Regards Frank Kabel Frankfurt, Germany "Andy" <amelton@gmail.com> schrieb...

how to convert date
Hi, I'm looking for some method to convert mail date, in format: eg. "Sun, 18 Sep 2005 20:57:08 +0200", to computer local time. I tried CTime but without resoults. m. Have you tried COleDateTime::ParseDateTime()? m.wski21.usunto@aust.com wrote: > Hi, > > I'm looking for some method to convert mail date, in format: > eg. "Sun, 18 Sep 2005 20:57:08 +0200", to computer local time. > I tried CTime but without resoults. > > m. >I'm looking for some method to convert mail date, in format: >eg. "Sun, 18 Sep 2005 20:57:08 +0200&qu...

Pocket Excel files (.pxl) do not open in Excel 2003 on XP desktop
I just tried to open a Pocket Excel file on my Windows XP desktop and the file could not be opened. Has anyone had any luck opening Pocket excel files on a desktop PC without converting them? Pocket Excel I believe is the .pxl format that the Handheld PC and the PocketPC use. I may want to password protect files and send them to a party that does not have a PocketPC. Can this be done, or do I need to convert the files to MS excel and password protect a seperate .zip file using resco File explorer? I cannot send any files to this party that are not password protected for the risk is to...

CHm file format
Hello, I have seen your's reference on code project. I am new to CHM format and i need to create a CHM viewer. I have some queries regarding the same a) what is binary TOC and binary index ( I have been able to parse the HHc and HHk fie). How i should parse the same b) What are merged files. How i can read them c) How how CHI, CHw and CHQ files can be created. How reading of these files will be different form the reading CHM file. Please help me out by answering my queries. Thanks, Ritu ...

How do I convert dates to text keeping the format?
I'm trying to convert a column of data in date format *m/d/yyyy to a text format without converting to serial numbers. Ie: I want to retain the mm/dd/yyyy format. Is there a way to do this? =TEXT(A1,"MM/DD"/YYYY") "sprlarry" <sprlarry@discussions.microsoft.com> wrote in message news:69669AA6-FD15-47D7-843D-FC768728BF7A@microsoft.com... > I'm trying to convert a column of data in date format *m/d/yyyy to a text > format without converting to serial numbers. Ie: I want to retain the > mm/dd/yyyy format. Is there a way to do this? That ...

How do I bring up a file that I saved as an Excel file?
I am taking classes and have to do work on Excel and was wondering why when I save them I can't retrieve them? I can see the file names but am not able to retrieve them I am inexperienced on Office. Hi open excel, choose file & open, locate your files, click on the one you want to open and press the Open button. however, if the files that you want to open are on a floppy disk then it is a VERY good idea to copy them onto your hard drive before opening them. This is best achieved using windows explorer. to do this: right mouse click on the start button choose explore ensure the flo...

naming convention for PNG resources?
So IDB_xxx is for bitmaps, IDS_xxx is for strings, etc. Is there one for PNGs? I know MFC doesn't support PNG "as is". I thought about IDP_xxx but thats taken. IDPNG_xxx or ID_PNG_xxx seems weird. Invent one. Why is IDPNG_ unacceptable? The names are arbitrary. joe On Sun, 16 Dec 2007 21:30:14 -0800, "Somebody" <somebody@cox.net> wrote: >So IDB_xxx is for bitmaps, IDS_xxx is for strings, etc. Is there one for >PNGs? I know MFC doesn't support PNG "as is". I thought about IDP_xxx but >thats taken. IDPNG_xxx or ID_PNG_xxx seems w...

Excel: Auto converting text to numbers
I am downloading an Excel sheet, and the numbers come in as text. It basically comes in as "33 %" but Excel registers this as text, not a percentage. I have a cell that will be used to add the numbers, but since they are text it doesn't work. Given this information, is there a way to convert the imported data into numbers. I would prefer to include this into my formula. The potential numbers are: 0, 1, 2, 3, 4, 0 %, 25 %, 33 %, 50 %, 67 %, 75 %, 100 %, and N/A I would prefer a function, again if possible, that could convert any number. Please note, the space between the nu...

Convert Access97 to 2000
Hello, we're currently running access97 and would like to convert it to 2000, but we don't know what is the administrator password for this database. Also this database is running on multi user and have difference permission for diffence users. Could someone help me how to do make this happen but keep the currently permission retaint. Thanks ...

Attach file vs insert file
I have a user who is trying to attach a file to an email (Exchange 2003 SP2, Outlook 2003) using the paperclip icon. Instead of attaching to the email (adding an Attach: line under the Subject line) Outlook is inserting the file into the body of the email. Any suggestions? TOP wrote: > I have a user who is trying to attach a file to an email (Exchange 2003 SP2, > Outlook 2003) using the paperclip icon. Instead of attaching to the email > (adding an Attach: line under the Subject line) Outlook is inserting the > file into the body of the email. > > Any suggestions?...

Excel file save macro.
I need help with a macro. I want to be able to save a file as a listed name, that is referenced in a cell, in a directory that is listed in a different cell. ------------------------------------------------ ~~ Message posted from http://www.ExcelTip.com/ ~~ View and post usenet messages directly from http://www.ExcelForum.com/ Post your efforts. Homework? "darrenlshipley" <darrenlshipley.vecxb@excelforum-nospam.com> wrote in message news:darrenlshipley.vecxb@excelforum-nospam.com... > I need help with a macro. I want to be able to save a file as a listed > name, tha...

Cannot double click an excel file and open it.
Hi When I double click an excel file, the excel application opens with a grey screen. If I drag the file onto the grey screen it opens fine. If I double click an excel attachement the excel screen opens grey and I get a message box saying The system cannot find the file specified. If I drag an excel file into the outlook inbox and then double click on it, it launches as it would normaly. I have un associated and re associated the file with Excel. I have checked the selections under the window menu in Excel, but unhide is greyed out, indicating that excel has opened, but not loaded the fil...

how to convert excel's .cvf file to .csv file
...

Files Publisher cannot open.
After creating files in Publisher 2003, most will not open. I get the message"Publisher cannot open this file". ---------------- This post is a suggestion for Microsoft, and Microsoft responds to the suggestions with the most votes. To vote for this suggestion, click the "I Agree" button in the message pane. If you do not see the button, follow this link to open the suggestion in the Microsoft Web-based Newsreader and then click "I Agree" in the message pane. http://www.microsoft.com/office/community/en-us/default.mspx?mid=cbbcbdd8-ef0a-412a-9a74-65ca4bb16...

Convert 2000 Calendar to web page
Greetings, When I convert my calendar for 2005 to a webpage, the page is off by 1 day. Is there a template or fix available to fix this? Thanks, Duane I can edit the html file but this should not be the case. Fixes? Suggestions...other than use Apple? "Duane Perry" <dlp_sr@yahoo.com> wrote in message news:yZRtd.5561$0r.1710@newsread1.news.pas.earthlink.net... > Greetings, > > When I convert my calendar for 2005 to a webpage, the page is off by 1 day. > Is there a template or fix available to fix this? > > Thanks, > > Duane > > Duane, ...

XML Note convert to DataSet
Hello, I have this function: object acmResponse = acmLogin.acmString("4001", "", paramFormLogin + paramUserBasics);System.Xml.XmlNode[] acmNodes = (System.Xml.XmlNode[])acmResponse; What I have todo, to convert the XML Object in the DataSet Object? Thank you Matthias ...

Can I import a windows explorer list of files into an Excel sprea.
I was wondering if it is possible to import the list of files within a particular folder that one sees when using Windows Explorer, into an Excel spreadsheet? I am using WinXP and Office2003. modify to suit Sub GetFileList() Dim iCtr As Integer With Application.FileSearch .NewSearch .LookIn = "c:\aa" .SearchSubFolders = True .Filename = ".xls" If .Execute > 0 Then For iCtr = 1 To .FoundFiles.Count Cells(iCtr, 1).Value = .FoundFiles(iCtr) Next iCtr End If End With End Sub -- Don Guillett SalesAid Software donaldb@281....

Problem converting from Quicken to M2005
My Quicken files are mostly investment related, and generally converted fine. However all bonds (regular and muni's) converted as Investment type: Mutual Fund, not Bond. (1) How do I prevent that, (2) How do you change the Investment Type for an item? Thank you. In microsoft.public.money, Mike wrote: >My Quicken files are mostly investment related, and generally >converted fine. However all bonds (regular and muni's) converted as >Investment type: Mutual Fund, not Bond. (1) How do I prevent that, (2) Money typically converts custom data types from Quicken into funds. I thou...

How to access vrge file
I work at a law firm and need to review a number of vrge files. Are vrge file individual email files or are they the equivalent of a pst file which is a collection of emails, calendar, contacts, etc? We don't use Macs so we need the ability to view on a PC if possible. If that is NOT possible we can borrow a Mac. What is the best way to be able to view these vrge files on any platform? Thanks, Tom On 2/12/10 8:35 AM, in article FF3C8F86-C268-4129-96D3-693FD6F511CB@microsoft.com, "SoxFaninVA" <tjubb@hot.mail.spam.com> wrote: > I work at a law f...

Offline Folder File Settings and changed local profile folder path
We have a serious problem with Outlook 2003 and Cached Exchange Mode Situation: - we use roaming profiles - in Outlook the Cached Exchange Mode is activated - the OST-file is saved in the local profile folder A while ago our user names have been changed. On all laptops a local profile folder is created with the old user name. The full path to the OST-file is saved in the mail settings, for example "C:\Documents and Settings\<old user name>\Local Settings\Application Data\Microsoft\Outlook\outlook.ost" When the user log on to a laptop on which he didn't wor...

Convert
Is it possible to convert a Money file created in the USA version to that of the UK version? Thanks in advance The general way is QIF Export then Import. It's involved and has limitations like loan accounts don't QIF. See http://www.bollar.org/msmoney/#Q1. "Crispy" <nowayspammers@hotmail.com> wrote in message news:uQKSfzfyDHA.2500@TK2MSFTNGP09.phx.gbl... > Is it possible to convert a Money file created in the USA version to that of > the UK version? ...

calculate data from a different file
Is it possible to have a cell return a value from another file that is saved on a server without that file being opened. Here is the formula I am using: =COUNTIF(OFFSET('P:\Manpower\[Copy of Manpower 10-25 to 12-30.xls]Daily MP'!$A:$A,0,MATCH(F$3,'P:\Ohio\Manpower\[Copy of Manpower 10-25 to 12-30.xls]Daily MP'!$5:$5,0)-1),"*" & $B5 & "*") but all I get is #VALUE! if this file is not open on the PC I'm using. ...