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. Other Discussions
  3. The Weird and The Wonderful
  4. Ugly or a horror?

Ugly or a horror?

Scheduled Pinned Locked Moved The Weird and The Wonderful
question
10 Posts 6 Posters 0 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.
  • N Offline
    N Offline
    Naturality
    wrote on last edited by
    #1

    I wrote this at 4AM the other morning :S I'm a little embarrassed. But it's still doing it's bit in my program.

    for(int y = 0; y < bmp.biHeight; y=y+3){
    for(int x = 0; x < bmp.biWidth; x=x+3){
    for(int i = 0; i < 9; i++){
    int yp=0, xp=0;
    get_pixel(x+xp,y+yp,blank[i]);
    if(xp<3)
    xp++;
    else{
    xp = 0;
    yp++;
    }}
    avg(blank, Merge, 9);
    set_pixel(x,y,Merge);
    for(int i = 0; i < 9; i++){
    blank[i].rgbtBlue=0;
    blank[i].rgbtGreen=0;
    blank[i].rgbtRed=0;
    }
    clear_pixel(Merge);
    yp=0, xp=0;
    }}

    "Sir, I protest. I am NOT a merry man!"

    L A S S P 5 Replies Last reply
    0
    • N Naturality

      I wrote this at 4AM the other morning :S I'm a little embarrassed. But it's still doing it's bit in my program.

      for(int y = 0; y < bmp.biHeight; y=y+3){
      for(int x = 0; x < bmp.biWidth; x=x+3){
      for(int i = 0; i < 9; i++){
      int yp=0, xp=0;
      get_pixel(x+xp,y+yp,blank[i]);
      if(xp<3)
      xp++;
      else{
      xp = 0;
      yp++;
      }}
      avg(blank, Merge, 9);
      set_pixel(x,y,Merge);
      for(int i = 0; i < 9; i++){
      blank[i].rgbtBlue=0;
      blank[i].rgbtGreen=0;
      blank[i].rgbtRed=0;
      }
      clear_pixel(Merge);
      yp=0, xp=0;
      }}

      "Sir, I protest. I am NOT a merry man!"

      L Offline
      L Offline
      luckeryin
      wrote on last edited by
      #2

      hehe

      come on

      1 Reply Last reply
      0
      • N Naturality

        I wrote this at 4AM the other morning :S I'm a little embarrassed. But it's still doing it's bit in my program.

        for(int y = 0; y < bmp.biHeight; y=y+3){
        for(int x = 0; x < bmp.biWidth; x=x+3){
        for(int i = 0; i < 9; i++){
        int yp=0, xp=0;
        get_pixel(x+xp,y+yp,blank[i]);
        if(xp<3)
        xp++;
        else{
        xp = 0;
        yp++;
        }}
        avg(blank, Merge, 9);
        set_pixel(x,y,Merge);
        for(int i = 0; i < 9; i++){
        blank[i].rgbtBlue=0;
        blank[i].rgbtGreen=0;
        blank[i].rgbtRed=0;
        }
        clear_pixel(Merge);
        yp=0, xp=0;
        }}

        "Sir, I protest. I am NOT a merry man!"

        A Offline
        A Offline
        amweiss
        wrote on last edited by
        #3

        Did I miss something? isn't: yp=0, xp=0; out of scope?

        N 1 Reply Last reply
        0
        • A amweiss

          Did I miss something? isn't: yp=0, xp=0; out of scope?

          N Offline
          N Offline
          Naturality
          wrote on last edited by
          #4

          Yeah, that was an error I have since fixed. long xp=0, yp=0 was defined before this segment. Only after did I realise I had 'int'ed them.

          "Sir, I protest. I am NOT a merry man!"

          A 1 Reply Last reply
          0
          • N Naturality

            Yeah, that was an error I have since fixed. long xp=0, yp=0 was defined before this segment. Only after did I realise I had 'int'ed them.

            "Sir, I protest. I am NOT a merry man!"

            A Offline
            A Offline
            amweiss
            wrote on last edited by
            #5

            Did you also realize that you haven't 'int'ed them, you actually have 2 new variables defined in the scope of the inner loop? :-P the long ones are only being assigned 0 every time that loop executes and thats it. Scope is a wonderful thing, but it can also come back to bite you if you aren't careful.

            N 1 Reply Last reply
            0
            • A amweiss

              Did you also realize that you haven't 'int'ed them, you actually have 2 new variables defined in the scope of the inner loop? :-P the long ones are only being assigned 0 every time that loop executes and thats it. Scope is a wonderful thing, but it can also come back to bite you if you aren't careful.

              N Offline
              N Offline
              Naturality
              wrote on last edited by
              #6

              Yes... that was the error I fixed.

              "Sir, I protest. I am NOT a merry man!"

              1 Reply Last reply
              0
              • N Naturality

                I wrote this at 4AM the other morning :S I'm a little embarrassed. But it's still doing it's bit in my program.

                for(int y = 0; y < bmp.biHeight; y=y+3){
                for(int x = 0; x < bmp.biWidth; x=x+3){
                for(int i = 0; i < 9; i++){
                int yp=0, xp=0;
                get_pixel(x+xp,y+yp,blank[i]);
                if(xp<3)
                xp++;
                else{
                xp = 0;
                yp++;
                }}
                avg(blank, Merge, 9);
                set_pixel(x,y,Merge);
                for(int i = 0; i < 9; i++){
                blank[i].rgbtBlue=0;
                blank[i].rgbtGreen=0;
                blank[i].rgbtRed=0;
                }
                clear_pixel(Merge);
                yp=0, xp=0;
                }}

                "Sir, I protest. I am NOT a merry man!"

                S Offline
                S Offline
                StevenWalsh
                wrote on last edited by
                #7

                How fast does that run? in my experience using GetPixel and SetPixel are extremely slow

                N 1 Reply Last reply
                0
                • S StevenWalsh

                  How fast does that run? in my experience using GetPixel and SetPixel are extremely slow

                  N Offline
                  N Offline
                  Naturality
                  wrote on last edited by
                  #8

                  Fast enough that changing it would have no observable change. ;P But then, that may just be the fruits of overclocking.

                  "Sir, I protest. I am NOT a merry man!"

                  1 Reply Last reply
                  0
                  • N Naturality

                    I wrote this at 4AM the other morning :S I'm a little embarrassed. But it's still doing it's bit in my program.

                    for(int y = 0; y < bmp.biHeight; y=y+3){
                    for(int x = 0; x < bmp.biWidth; x=x+3){
                    for(int i = 0; i < 9; i++){
                    int yp=0, xp=0;
                    get_pixel(x+xp,y+yp,blank[i]);
                    if(xp<3)
                    xp++;
                    else{
                    xp = 0;
                    yp++;
                    }}
                    avg(blank, Merge, 9);
                    set_pixel(x,y,Merge);
                    for(int i = 0; i < 9; i++){
                    blank[i].rgbtBlue=0;
                    blank[i].rgbtGreen=0;
                    blank[i].rgbtRed=0;
                    }
                    clear_pixel(Merge);
                    yp=0, xp=0;
                    }}

                    "Sir, I protest. I am NOT a merry man!"

                    S Offline
                    S Offline
                    Stephen Hewitt
                    wrote on last edited by
                    #9

                    I can't even be assed looking at code formatted like that – incomprehensible! The first thing I do at work when I encounter rubbish like that is re-format it.

                    Steve

                    1 Reply Last reply
                    0
                    • N Naturality

                      I wrote this at 4AM the other morning :S I'm a little embarrassed. But it's still doing it's bit in my program.

                      for(int y = 0; y < bmp.biHeight; y=y+3){
                      for(int x = 0; x < bmp.biWidth; x=x+3){
                      for(int i = 0; i < 9; i++){
                      int yp=0, xp=0;
                      get_pixel(x+xp,y+yp,blank[i]);
                      if(xp<3)
                      xp++;
                      else{
                      xp = 0;
                      yp++;
                      }}
                      avg(blank, Merge, 9);
                      set_pixel(x,y,Merge);
                      for(int i = 0; i < 9; i++){
                      blank[i].rgbtBlue=0;
                      blank[i].rgbtGreen=0;
                      blank[i].rgbtRed=0;
                      }
                      clear_pixel(Merge);
                      yp=0, xp=0;
                      }}

                      "Sir, I protest. I am NOT a merry man!"

                      P Offline
                      P Offline
                      Paul Conrad
                      wrote on last edited by
                      #10

                      Nothing too bad there. One of the most "elegant" pieces of code I wrote in college was done after pounding down a fifth of tequila :-\ It was an amazing piece of work that worked very well.

                      "The clue train passed his station without stopping." - John Simmons / outlaw programmer "Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon

                      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