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
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Help! Figure out whats wrong! FOR LOOP-ing!

Help! Figure out whats wrong! FOR LOOP-ing!

Scheduled Pinned Locked Moved C / C++ / MFC
helpcsharp
6 Posts 4 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    colormyiris
    wrote on last edited by
    #1

    hello all.. i need some help to solve my problem.. i'd tried so many times to test this program... it works very well if i did not include the FOR LOOP into my program. i hope you guys can have a look at my program and figure out what mistakes i did..thanks.. COLORREF OriginalPixelValue; COLORREF NewPixelValuesss; int PixelCount=0; CoX=0; //coordinate-X CoY=0; //coordinate-Y for(int abcde=0; abcde<48; abcde++) { OriginalPixelValue=PixelValue(CoX,CoY); NewPixelValuesss=(OriginalPixelValue | Data_0[PixelCount]) & Data_1[PixelCount]; GoWatermark(NewPixelValuesss,CoX,CoY); PixelCount+=1; if(CoX} COLORREF CThongThongThongDlg::PixelValue(unsigned int cox, unsigned int coy) { m_pixelvalue=GetPixel(m_dcMem1, cox, coy); return m_pixelvalue; } BOOL CThongThongThongDlg::GoWatermark(unsigned long ValueValue, int CoordinateX, int CoordinateY) { NewSettedPixelValue=m_dcMem1.SetPixel(CoordinateX, CoordinateY, ValueValue); UpdateData(FALSE); return TRUE; } please take note at those lines in [B]BOLD[/B] .. when i put in this lines..to loop... the function does go..(i mean..the results i got is nothing...not working).. but if i delete those lines(those loops)..the function will run properly.. i really need to loop..its very important.. this is a school project.. where i need to read the bits values inside the 24-bit BITMAPS and do some modification of its RGB LSB.. i really need help. thanks a lot. thong twh81@tm.net.my ...

    T D 2 Replies Last reply
    0
    • C colormyiris

      hello all.. i need some help to solve my problem.. i'd tried so many times to test this program... it works very well if i did not include the FOR LOOP into my program. i hope you guys can have a look at my program and figure out what mistakes i did..thanks.. COLORREF OriginalPixelValue; COLORREF NewPixelValuesss; int PixelCount=0; CoX=0; //coordinate-X CoY=0; //coordinate-Y for(int abcde=0; abcde<48; abcde++) { OriginalPixelValue=PixelValue(CoX,CoY); NewPixelValuesss=(OriginalPixelValue | Data_0[PixelCount]) & Data_1[PixelCount]; GoWatermark(NewPixelValuesss,CoX,CoY); PixelCount+=1; if(CoX} COLORREF CThongThongThongDlg::PixelValue(unsigned int cox, unsigned int coy) { m_pixelvalue=GetPixel(m_dcMem1, cox, coy); return m_pixelvalue; } BOOL CThongThongThongDlg::GoWatermark(unsigned long ValueValue, int CoordinateX, int CoordinateY) { NewSettedPixelValue=m_dcMem1.SetPixel(CoordinateX, CoordinateY, ValueValue); UpdateData(FALSE); return TRUE; } please take note at those lines in [B]BOLD[/B] .. when i put in this lines..to loop... the function does go..(i mean..the results i got is nothing...not working).. but if i delete those lines(those loops)..the function will run properly.. i really need to loop..its very important.. this is a school project.. where i need to read the bits values inside the 24-bit BITMAPS and do some modification of its RGB LSB.. i really need help. thanks a lot. thong twh81@tm.net.my ...

      T Offline
      T Offline
      Ted Ferenc
      wrote on last edited by
      #2

      Is this a "deliberate" typo? if(CoX { CoX+=1; } Shouldn't it be if(CoX) { Cox += 1; } else { CoY+=1; CoX=0; }


      It is amazing what you can accomplish if you do not care who gets the credit. - Harry S Truman

      D 1 Reply Last reply
      0
      • T Ted Ferenc

        Is this a "deliberate" typo? if(CoX { CoX+=1; } Shouldn't it be if(CoX) { Cox += 1; } else { CoY+=1; CoX=0; }


        It is amazing what you can accomplish if you do not care who gets the credit. - Harry S Truman

        D Offline
        D Offline
        David Crow
        wrote on last edited by
        #3

        His code is actually:

        if(CoX < m_bmInfo1.bmWidth)
        {
        CoX+=1;
        }
        else
        {
        CoY+=1;
        CoX=0;
        }

        T 1 Reply Last reply
        0
        • C colormyiris

          hello all.. i need some help to solve my problem.. i'd tried so many times to test this program... it works very well if i did not include the FOR LOOP into my program. i hope you guys can have a look at my program and figure out what mistakes i did..thanks.. COLORREF OriginalPixelValue; COLORREF NewPixelValuesss; int PixelCount=0; CoX=0; //coordinate-X CoY=0; //coordinate-Y for(int abcde=0; abcde<48; abcde++) { OriginalPixelValue=PixelValue(CoX,CoY); NewPixelValuesss=(OriginalPixelValue | Data_0[PixelCount]) & Data_1[PixelCount]; GoWatermark(NewPixelValuesss,CoX,CoY); PixelCount+=1; if(CoX} COLORREF CThongThongThongDlg::PixelValue(unsigned int cox, unsigned int coy) { m_pixelvalue=GetPixel(m_dcMem1, cox, coy); return m_pixelvalue; } BOOL CThongThongThongDlg::GoWatermark(unsigned long ValueValue, int CoordinateX, int CoordinateY) { NewSettedPixelValue=m_dcMem1.SetPixel(CoordinateX, CoordinateY, ValueValue); UpdateData(FALSE); return TRUE; } please take note at those lines in [B]BOLD[/B] .. when i put in this lines..to loop... the function does go..(i mean..the results i got is nothing...not working).. but if i delete those lines(those loops)..the function will run properly.. i really need to loop..its very important.. this is a school project.. where i need to read the bits values inside the 24-bit BITMAPS and do some modification of its RGB LSB.. i really need help. thanks a lot. thong twh81@tm.net.my ...

          D Offline
          D Offline
          David Crow
          wrote on last edited by
          #4

          I can see two things that the for loop might affect. 1) the incrementing of PixelCount. This is used in the dereferencing of Data_0 and Data_1. Are the arrays large enough? 2) the incrementing of CoX and CoY. Those are used by PixelValue() and GoWatermark(). Can those functions handle values greater than 0?

          1 Reply Last reply
          0
          • D David Crow

            His code is actually:

            if(CoX < m_bmInfo1.bmWidth)
            {
            CoX+=1;
            }
            else
            {
            CoY+=1;
            CoX=0;
            }

            T Offline
            T Offline
            Ted Ferenc
            wrote on last edited by
            #5

            Thanks, that is not what I see on IE6! Perhaps he could give a link to the source code? I could not see anything obviously wrong. But it could have been screwed durin cut/paste.


            It is amazing what you can accomplish if you do not care who gets the credit. - Harry S Truman

            A 1 Reply Last reply
            0
            • T Ted Ferenc

              Thanks, that is not what I see on IE6! Perhaps he could give a link to the source code? I could not see anything obviously wrong. But it could have been screwed durin cut/paste.


              It is amazing what you can accomplish if you do not care who gets the credit. - Harry S Truman

              A Offline
              A Offline
              Andrew Allen
              wrote on last edited by
              #6

              I don't see it either. Looks like IE6 swallowed the "<" as an HTML tag. He needs to wrap his sample code with tags.

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

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