Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
W

walter76

@walter76
About
Posts
12
Topics
1
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Java IDE's?
    W walter76

    Yes, Java w a s slow, but it isn't anymore. I've developed Java Applications the last 5 years, since JDK 1.3 until 1.5 and there where a lot of improvements especially what relates performance. Java just had to solve the problems you have with every new language. And from the object oriented programming point of view the developers of Java have done a very good job. Don't misunderstand me, i know C/C++ as well as Java and there are issues i would always prefer C/C++ above Java, e. g. for os and driver programming. But i think it's simply not right to blame any language for bad performance etc. Every programming language has it's pros and cons and areas where it rules. To answer your question from the start. Eclipse is the best IDE for Java around. period. Besides it you could try the NetBeans project from SUN or use the good'ol vi editor and ant/maven for making a nice build environment. cu/walter

    The Lounge visual-studio csharp java com question

  • what can mingw do for me?
    W walter76

    if you are talking about MFC, then the answer is no. But you can develop core win api applications with it. if you are looking for a good toolkit, try QT from trolltech. it is free for developing non-commercial applications and it supports mingw as a compiler. if you are not lucky with QT, you can hava a look at wxwindows. hope that helps you out. walter

    C / C++ / MFC question

  • masking
    W walter76

    I am not sure what you mean with masking, but if you like to extract a hexadecimal value from a string and want to set the last 3 bits to 0 you can do it like this:

    #include <stdlib.h>
    #include <stdio.h>

    int main(int argc, char **argv) {
    char myHexString[] = "1A";
    unsigned char myByte = 0x0;
    sscanf(myHexString, "%X", &myByte);
    myByte &= 0xF8; // set the last three bits of the byte to 0
    printf("%d, 0x%x\n", myByte, myByte);
    return 0;
    }

    Hope that helps you out. Walter -- modified at 7:55 Thursday 2nd March, 2006

    C / C++ / MFC question

  • Class Design Question
    W walter76

    Hehehe! It is working as intended. You are thinking in-depth about your problem domain and the design. The way you mentioned in your last post sounds good to me. Make 2 classes one for the array and another for the file reading and parsing stuff. Do a composition of both, i. e. make the array class a member of the file reading class. Keep in mind to always start simple and extend your design as needed. Walter

    C / C++ / MFC help c++ question css database

  • Typecast _bstr_t to int?
    W walter76

    Don't know what you like to achieve, but if you are up to put a integer value into a string a type cast is the wrong way. Use atoi() to convert character arrays to integers. Hope this helped you out. Walter

    C / C++ / MFC question

  • Internet access application
    W walter76

    I don't know the MFC sample TEAR but as my experience shows these examples seldom use ssl connections. If you want to setup a https (ssl) connection take a look at openssl http://www.openssl.org/. A simple connection through a proxy (non-authenticating) is quite easy. First setup a simple connection to the proxy (you need a ssl connection if the proxy is https protected, too) and send a http request as explained in the codeproject article HTTP Tunneling (HTTP Proxy Socket Client). Hope i helped you out. Walter

    C / C++ / MFC c++ sysadmin windows-admin algorithms help

  • SetBitmapBits not Working as Expected
    W walter76

    Looks like i am on the right way now. Thanks again.

    C / C++ / MFC performance graphics tools question

  • SetBitmapBits not Working as Expected
    W walter76

    Yeah! Just found out that this is the problem. It seems SelectObject() for the bitmap is returning an error, because of the bitmap is not compatible with the device context. I think i change my strategy and have a look into device independent bitmaps (DIB). Maybe this solves my problem. Programming Windows API can be frustrating sometimes. The only thing i want to do is to put some raw 24bit RGB pixel data fast on to the screen. This can't be that difficult. Thanks for your help!

    C / C++ / MFC performance graphics tools question

  • SetBitmapBits not Working as Expected
    W walter76

    I tryed to cut it down, but i thought everything could be important. But your post shows that you haven't read the code, either. I use the calculated width from the bitmap info header bmWidthBytes. This is calculated by windows and 4 bytes aligned. I put traces in there and the height is calculated correct. If any of this values would be false there should be something on the screen at last and if it is only crap. But there is nothing, not a single pixel. I try to break the code down a bit:

    // create compatible memory dc
    CDC memDC;
    memDC.CreateCompatibleDC(pDC);
    
    // draw image into the bitmap
    CBitmap imageBitmap;
    BITMAP bmp;
    BYTE\* imageBits;
    BYTE\* pImageBits;
    
    imageBitmap.CreateBitmap(pImage->getWidth(), pImage->getHeight(), 1, 24, NULL);
    imageBitmap.GetBitmap(&bmp);
    imageBits = (BYTE\*) GlobalAlloc(GPTR, bmp.bmHeight \* bmp.bmWidthBytes);
    
    //... doing some pixel transform stuff
    
    if (imageBitmap.SetBitmapBits(bmp.bmHeight \* bmp.bmWidthBytes, imageBits) == 0) {
        AfxMessageBox("Could not set bitmap bits.");
    }
    
    GlobalFree((HGLOBAL) imageBits);
    
    // draw bitmap
    CBitmap\* pOldBitmap = memDC.SelectObject(&imageBitmap);
    if (pDC->BitBlt(0, 0, pImage->getWidth(), pImage->getHeight(), &memDC, 0, 0, SRCCOPY) ==0) {
        AfxMessageBox("BitBlt failed.");
    }
    memDC.SelectObject(pOldBitmap);
    
    C / C++ / MFC performance graphics tools question

  • Class Design Question
    W walter76

    You ask a difficult question here. In general a good class design is never easy to make. But try to think in a object-oriented way. First you should define what problem you want to solve. As i can suggest from your post, you made that already. Then try to define the classes. Start with the core of the problem. I try to explain what i do if i invent a new class design from scratch and hope that leads you in the right direction. 1. First i write the problem i like to solve on a piece of paper. I try to put the words in one simple sentence. That helps me to get a crip on the problem. 2. Then i start with the core class. In your case this would be something like C2DArray. I try to keep it as simple as possible first. What do i need the class to do: - read in a text file - store the data kept in the text file - store some header information - do some simple calculations These points already define me some member functions: - C2DArray(const char* filename) - readFile() - calculateSomething() - ... 3. After i got the first simple class i try it out with a simple application. In most cases this is a console application with a lot of printf's. 4. I put more functionality into the class. While i do this, i keep the following in mind: - If a member function gets too big and i don't understand what's going on anymore i split it in several subfunctions - If a class gets too big and i don't understand what's going on anymore i try to generalize parts of the class into a superclass In that way you will become more classes and functions on need and you don't get overwhelmed by a mass of classes from the start. About generalisation, operator overloading etc. Do this only if it is worth the effort and you need it for your application. There are so many class designs where people did operator overloading only cause it looked nice. I am not sure if this is what you needed. Hope it helps you out a bit. And i am sorry if my English isn't that good. It is not my native language. Walter

    C / C++ / MFC help c++ question css database

  • Converting HWnd to CWnd
    W walter76

    From the Documentation of the CWnd-Class: CWnd::m_hWnd Remarks The handle of the Windows window attached to this CWnd. The m_hWnd data member is a public variable of type HWND. CWnd::GetSafeHwnd HWND GetSafeHwnd( ) const; Return Value Returns the window handle for a window. Returns NULL if the CWnd is not attached to a window or if it is used with a NULL CWnd pointer. Hope this helps you out. Walter

    C / C++ / MFC question

  • SetBitmapBits not Working as Expected
    W walter76

    Hi there, i have written this function to draw a image held in raw pixel data in my own class to a window. It is not working as expected, say it doesn't draw a single pixel. Where is the fault? I am trying to solve this for days now and can't see where i made the mistake. Here comes the code.

    void CImageViewerView::drawImage(CDC* pDC, CpilImage* pImage) {
    // create compatible memory dc
    CDC memDC;
    memDC.CreateCompatibleDC(pDC);

    // draw image into the bitmap
    CBitmap imageBitmap;
    BITMAP bmp;
    BYTE\* imageBits;
    BYTE\* pImageBits;
    
    imageBitmap.CreateBitmap(pImage->getWidth(), pImage->getHeight(), 1, 24, NULL);
    imageBitmap.GetBitmap(&bmp);
    imageBits = (BYTE\*) GlobalAlloc(GPTR, bmp.bmHeight \* bmp.bmWidthBytes);
    
    for (unsigned int y = 0; y < pImage->getHeight(); y++) {
        unsigned int\* line = pImage->getPixelRegion(0, y, pImage->getWidth(), 1);
        unsigned int\* pLine = line;
    
        pImageBits = imageBits + (bmp.bmWidthBytes \* y);
        for (unsigned int x = 0; x < pImage->getWidth(); x++) {
            pImageBits\[0\] = getRedValue(pLine);
            pImageBits\[1\] = getGreenValue(pLine);
            pImageBits\[2\] = getBlueValue(pLine);
            pImageBits += 3;
            pLine++;
        }
    }
    if (imageBitmap.SetBitmapBits(bmp.bmHeight \* bmp.bmWidthBytes, imageBits) == 0) {
        AfxMessageBox("Could not set bitmap bits.");
    }
    
    GlobalFree((HGLOBAL) imageBits);
    
    // draw bitmap
    CBitmap\* pOldBitmap = memDC.SelectObject(&imageBitmap);
    if (pDC->BitBlt(0, 0, pImage->getWidth(), pImage->getHeight(), &memDC, 0, 0, SRCCOPY) ==0) {
        AfxMessageBox("BitBlt failed.");
    }
    memDC.SelectObject(pOldBitmap);
    

    }

    CpilImage is a class which stores a image plus the pixel data in rgb-quads. The getXXXValue()-functions are utility functions which extract the red, green and blue values from the quads. The class and functions are working, cause if i alter the function to work with CDC::SetPixelV() the image is drawn. But as this is very slow i tryed to speed it up with SetBitmapBits() and BitBlt() which seems to not work. Walter

    C / C++ / MFC performance graphics tools question
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups