Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8975047
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T18:47:15+00:00 2026-06-15T18:47:15+00:00

It possible get cutout of image data. If I know: byte[] ImageData; int width;

  • 0

It possible get cutout of image data.
If I know:

byte[] ImageData;
int width;
int height;

Basically I try find how get inner section of image from byte[] source.

For example I have image which is w: 1000px and h: 600px. And I want byte[] middle section 200*200px in byte[].

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T18:47:16+00:00Added an answer on June 15, 2026 at 6:47 pm

    First of all you need to know how many bytes in your array represent one pixel. The following assumes that you have an RGB image with 3 bytes per pixel.

    Then, the array-index of the first byte that represents the top-left corner of your cutout is represented as

    int i = y * w + x
    

    where y is the y-coordinate of the cutout, w is the width of the entire image and x is the x coordinate of the cutout.

    Then, you can do as follows:

    // cw: The width of the cutout
    // ch: The height of the cutout
    // x1/y1: Top-left corner coordinates
    
    byte[] cutout = new byte[cw * ch * 3]; // Byte array that takes the cutout bytes
    for (int cy = y1; cy < y2; cy++)
    {
        int i = cy * w + x1;
        int dest = (cy - y1) * cw * 3;
        Array.Copy(imagebytes, i, cutout, dest, cw * 3);
    }
    

    This iterates from the first to the last row to be cut out. Then, in i, it calculates the index of the first byte of the row in the image that should be cutout. In dest it calculates the index in cutout to which the bytes should be copied.

    After that it copies the bytes for the current row to be cut out into cutout at the specified position.

    I have not tested this code, really, but something like that should work. Also, please note that there’s currently no range checking – you need to make sure that the location and dimensions of the cutout are really within the bounds of the image.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Get image data in Javascript? Hello, I've got a single div, which
Possible Duplicates: Get image data in Javascript? How to encode image data within an
does anyone know how to (if possible) get the owner of the tag on
Possible Duplicate: Get variable name. javascript “reflection” Is there a way to know the
Possible Duplicate: Get the resolution of a jpeg image using C# and the .NET
Hi I would like to ask if its possible get array with clear data
Possible Duplicate: Get column index from label in a data frame I need to
Possible Duplicate: Get first day of week in PHP? Hi, I want to find
I am trying to work out if it is possible get JPA to persist
Possible Duplicate: Get file name from URI string in C# How to extract file

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.