• Content count

  • Joined

  • Last visited

Community Reputation

122 Neutral

About MitchellH

  • Rank
  1. Hello, So I think I managed to load a 16-bit bitmap correctly using the following code: bool CBitmap::Load(char *szFilename) { BITMAPFILEHEADER bmpHeader; BITMAPINFOHEADER bmpInfoHeader; unsigned char* pucPixels; char *szPath = new char[MAX_PATH]; GetModuleFileName(NULL, szPath, MAX_PATH); PathRemoveFileSpec(szPath); char *szFullPath = new char[strlen(szPath) + strlen(szFilename) + 2]; strcpy(szFullPath, szPath); strcat(szFullPath, "\\"); strcat(szFullPath, szFilename); delete[] szPath; std::ifstream isBitmap(szFullPath, std::ios::in | std::ios::binary); delete[] szFullPath; if (!isBitmap.is_open()) { (CError::GetInstance())->Notify("Failed to open bitmap for read.", "!isBitmap.is_open()"); return false; }<char *>(&bmpHeader), sizeof(bmpHeader)); if (bmpHeader.bfType != 0x4D42) { (CError::GetInstance())->Notify("Invalid Bitmap", "bfType != Valid Bitmap"); isBitmap.close(); return false; }<char *>(&bmpInfoHeader), sizeof(bmpInfoHeader)); if (bmpInfoHeader.biBitCount != 16) { (CError::GetInstance())->Notify("Invalid Bitmap Depth.", "Bitmap is not 16-bit."); isBitmap.close(); return false; } if (!(pucPixels = new unsigned char[bmpHeader.bfSize - bmpHeader.bfOffBits])) { (CError::GetInstance())->Notify("Not enough memory to load bitmap.", "Failed to allocate pucPixels."); isBitmap.close(); return false; }<char *>(pucPixels), bmpHeader.bfSize - bmpHeader.bfOffBits); isBitmap.close(); for (int nIndex = 0; nIndex < static_cast<int>(bmpHeader.bfSize); nIndex += 3) { unsigned char ucTempRGB = pucPixels[nIndex]; pucPixels[nIndex] = pucPixels[nIndex + 2]; pucPixels[nIndex + 2] = ucTempRGB; } m_pcPixels = pucPixels; m_nWidth = bmpInfoHeader.biWidth; m_nHeight = bmpInfoHeader.biHeight; return true; } Right? Well how, now, do I copy those pixels onto a surface? Help is much appreciated, thank you :) I used something such as this just to test out this method... bool CBitmap::Draw(unsigned char *pcDest) { unsigned char *pcPixels = m_pcPixels; for (int x = 0; x < m_nWidth; x++) { for (int y = 0; y < m_nHeight; y++) { pcDest[y] = pcPixels[y]; } pcPixels += m_nWidth; pcDest += m_nWidth; } return true; } And also, when I quit the program, I get an error when I attempt to delete[] m_pcPixels. I can't figure out why...
  2. how to change a string?

    Change the if (a == 1) to if (a == "1") Illco said this already.
  3. #include Syntax

    Quote:Original post by Arild Fines Quote:Original post by Fruny #include "whatever.bork" Is that the new extension in C++0X? Basically: lmao.
  4. Ive been making an HTTP winsock wrapper and its all working great except for when i recv the data. I have narrowed down the problem to here: char buffer[100]; *data = ""; err = 100; while (err == 100) { strset(buffer, ' '); err = recv(theSocket, buffer, sizeof(buffer), 0); cout << err << "\n"; *data += buffer; }; data is a string. The fatal exception seems to occur after its done receiving (when err != 100) This is my first time using winsock and im sure there are better ways to receive so if you have any suggestions id be glad to hear them. :) EDIT: Also, the socket is connected and a GET request was successfully sent. The data being returned is also correct (from what i saw in my packet sniffer) [Edited by - MitchellH on November 27, 2004 12:38:43 PM]
  5. I have binary numbers down pretty good now. I read John Selvia's tutorials on counting binary numbers on your fingers and it helps a lot in converting back and forth very quickly :) (but only up to 1023)
  6. Alright. I forgot that this should go into the Math forum...
  7. Over my years of learning programming, ive learned that binary and hexadecimal numbers are very important. I have learned each maybe once or twice but not enough to truly remember them. I am looking for a quality tutorial that you would recommend as a way to learn and practice binary/hex numbers. Thank you :)
  8. string undeclared identifier?

    Thank you very much thooms. That did work although I couldve sworn i tried that before and it was saying that std was not a defined namespace. Oh well, it works now :)
  9. Im trying to use the C++ string object but when I compile, its yelling at me that its undeclared. I include string.h and looked through string.h and its not there #include <stdio.h> #include <iostream.h> #include <string.h> int main(int argc, char* argv[]) { string name = ""; cin >> name; cout << name; return 0; } Its a useless program since I just want the compile to work for now. EDIT: Also, Im using VC++6
  10. Thank you guys. I was always planning on using the iostream library since it did type conversions and the like, but for reference i wanted to know what the difference was. Thanks again!
  11. Hi, I know about the iostream standard library and the stdio. I was wondering whats the advantages/disadvantages of using iostream over stdio's printf, scanf, etc. Noob question :) Thanks, Mitchell H.
  12. Ah thanks yes my code look similar to that but the way the data is stored is slightly more complicated. I think i'll change the way its stored rather than have to deal with it. Also, you develop palm apps in delphi?
  13. Loading tiles from one large image

    I am not used to windows programmer or familiar with the SDL API but I can say that the easiest way would be to clip the rectangle of your tile. I dont know how this is done but its usually done along the lines of: 1.) Specifying the top-corner x and y values of the tile. Also specifying the width and height, in this case being 64 and 64. 2.) Running tha tthrough a function to copy it to another surface 3.) Doing whatever with that EDIT: thisisbob posted same time as me
  14. Well I'd like to learn as much as I could. I have made some basic wrappers also for creating, inserting, etc. but for some reason the reading doesnt always work. I guess I'll play around w/ it again im sure its some weird bug. I just wanted to see some good examples of databases being used.
  15. Hi, I entered the world of Palm OS programming early this year and have been successfully programming games for Palm OS (personal, non-released games). I have always wanted to learn about using palm databases and have not been able to find a decent article or tutorial on it. I have googled and found a couple tutorials. One confused me more than helped me, the other was much too short and covered very little and also spent much too much time on storing strings in a pdb. If you have any suggestions as to where I can read up on this subject, please post here. Thank you, Mitchell H.