working with images as byte[] arrays

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Stephen.Schoenberger@gmail.com

    working with images as byte[] arrays

    I am working with some images as byte[] arrays and am not sure nor can
    I figure out if as I am reading the image and saving smaller sub-
    images I am reading across and down the image or down and back up or
    randomly? I need to know so in turn I can realize what the coordinates
    are of the sub-images. Here is a snippet of the code that is
    performing this task...

    for (int a = 1; a < 4800; a++) //will create 4800 sub images if a
    goes to numsubimages
    {
    Bitmap tempbitmap;
    //this declares the size of tbyte to be 768 which is
    the number of bytes needed for 16x16 sub image
    byte[] tbyte = new byte[(stride * height) / ((height /
    16) * (width / 16))];
    byte[] holding2 = new byte[tbyte.Length];

    for (int b = 1; b < tbyte.Length; b++)
    {
    tbyte.Initializ e();
    byte holding = (byte) bytebitmap.GetV alue(b*a);
    tbyte.SetValue( holding, b);

    }
    tempbitmap = BytesToBmp(tbyt e, tempSize); //save the
    output of the 16x16 sub image so results can be seen
    }

    BytesToBmp is simply a function that coverts a byte array into a
    bitmap image.

    Thanks!
  • zacks@construction-imaging.com

    #2
    Re: working with images as byte[] arrays

    On Feb 7, 1:14 pm, Stephen.Schoenb er...@gmail.com wrote:
    I am working with some images as byte[] arrays and am not sure nor can
    I figure out if as I am reading the image and saving smaller sub-
    images I am reading across and down the image or down and back up or
    randomly? I need to know so in turn I can realize what the coordinates
    are of the sub-images. Here is a snippet of the code that is
    performing this task...
    >
     for (int a = 1; a < 4800; a++) //will create 4800 sub images if a
    goes to numsubimages
    {
                    Bitmap tempbitmap;
                    //this declares the size of tbyte to be 768 which is
    the number of bytes needed for 16x16 sub image
                    byte[] tbyte = new byte[(stride * height) / ((height /
    16) * (width / 16))];
                    byte[] holding2 = new byte[tbyte.Length];
    >
                    for (int b = 1; b < tbyte.Length; b++)
                    {
                        tbyte.Initializ e();
                        byte holding = (byte) bytebitmap..Get Value(b*a);
                        tbyte.SetValue( holding, b);
    >
                    }
                    tempbitmap = BytesToBmp(tbyt e, tempSize); //save the
    output of the 16x16 sub image so results can be seen
    >
    }
    >
    BytesToBmp is simply a function that coverts a byte array into a
    bitmap image.
    >
    Thanks!
    What is the input file type? I don't think this method would work for
    a compressed image file like JPG.

    Comment

    Working...