Take pixels values from pic with specifiec order

This is a discussion on Take pixels values from pic with specifiec order within the Windows Programming forums, part of the Platform Specific Boards category; Hi one good question. I have one pic 3X3. Width=3 Height=3 let say with values: 0 1 2 3 4 ...

  1. #1
    Registered User
    Join Date
    Jul 2006
    Posts
    43

    Take pixels values from pic with specifiec order

    Hi
    one good question.
    I have one pic 3X3. Width=3 Height=3

    let say with values:

    0 1 2
    3 4 5
    6 7 8
    With 2 for (1 for width and 1 for height)i was able to take that values and save to one dimension array with that way:
    PixelValues=0,3,6,1,4,7,2,5,8
    My question:
    Is possible to take that values with that order: 4,5,8,7,6,3,0,1,2.
    Is possible to do that with for?? Or i need something else???
    The method i use is PixelValues=Image1->Canvas->Pixels[i][j];

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,420
    Sure, why not.

    Draw out a 5x5 and 7x7 and 9x9 array of pixels and trace out the paths.

    Something like
    R1,D1
    L2,U2,R2
    D3.....

    When you actually spot the pattern for the general case, then you can go away and implement some code which scans the image in the order you want it to.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  3. #3
    Registered User
    Join Date
    Jul 2006
    Posts
    43
    I didnt get it. My example is for small array. I have to do it for big arrays from pics. My problem is to do it while i save the values in pic array.

    code:

    int x=Image1->Height;
    int y=Image1->Width;

    for(i=0;i<x;i++)
    for(j=0;j<y;j++)
    Pic1Values=Image->Canvas->Pixels[i][j];

    now i have that code and i took values with the order i said in 3*3 array. I want to start from center and go right and down and left., like i said in 3*3 array. I possible that with for??? or another way? Can you explain your method with code?? Or other ideas in my code??

  4. #4
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,420
    Right 1
    Down 1
    Left 2
    Up 2

    Work out how the sequence of run lengths progresses as you spiral out from the centre of the bitmap.
    Then write some code to modify the values of 'i' and 'j' according to those rules.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  5. #5
    Registered User
    Join Date
    Jul 2006
    Posts
    43
    Thats the problem, i dont know what to do or where to look to make the code you say. I still dont get it.
    What is Right=1 Down=1 Left=2 up=2. What you mean by that??????
    Oh and another problem the pics are not only bitmap. They are jpeg,png,tif etc.

  6. #6
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,420
    Oh ffs, DRAW some grids out and work out the pattern.

    Say just for arguments sake the run lengths go 1,1,2,2,3,3,4,4,5,5

    int i = width / 2;
    int j = height / 2;
    int runlen = 1;

    Treat middle as a special case
    processPixel(i,j);

    Then spiral outwards
    for ( n = 0 ; n < runlen ; n++ ) processPixel(++i,j); // Right
    for ( n = 0 ; n < runlen ; n++ ) processPixel(i,++j); // Down
    runlen++;
    for ( n = 0 ; n < runlen ; n++ ) processPixel(--i,j); // L
    for ( n = 0 ; n < runlen ; n++ ) processPixel(i,--j); // U
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  7. #7
    Registered User
    Join Date
    Jul 2006
    Posts
    43
    Ok. But i use the method Image1->Canvas->Pixels[i][j] is possible to use that you say on that?? And you use 4 for how the array will save the values??? Because you stop one for and then start another. The array with first 2 for will save some values and after?? will continue with second 2 for?? from where it stoped??
    and what is ProcessPixels?? Is method?? What will be the array?? what is variable n??
    Last edited by Leite33; 11-04-2006 at 12:54 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. How do you order your game code?
    By Queatrix in forum A Brief History of Cprogramming.com
    Replies: 15
    Last Post: 02-05-2006, 05:26 PM
  2. Comparing values
    By hdragon in forum C++ Programming
    Replies: 2
    Last Post: 10-06-2005, 05:09 PM
  3. organize values of array in ascending order
    By incognito in forum C++ Programming
    Replies: 4
    Last Post: 11-08-2003, 09:55 PM
  4. what is the significance of low order and high order bits
    By Shadow12345 in forum Windows Programming
    Replies: 1
    Last Post: 11-16-2002, 10:46 AM
  5. File access question
    By Imperito in forum C++ Programming
    Replies: 5
    Last Post: 04-19-2002, 11:37 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21