473,661 Members | 2,429 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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!
Feb 7 '08 #1
1 2225
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.
Feb 7 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
7225
by: Eric Hendriks | last post by:
// In an unmanaged DLL the following function must be called: // int VFGeneralize(const BYTE * const * features); // "features" parameter is supposed to be an array of byte arrays. // function is Marshaled as follows: static extern int VFGeneralize(byte features); In C# I have the following: // Allocate memory to store "Count" references to byte arrays
10
1923
by: Eric Eggermann | last post by:
Hello all, I'm looking for a way to tell whether two image objects which do not have object equality are the same image or not, and I mean identical, say originally loaded from the same file. Any ideas on how to approach this? TIA, Eric
8
3401
by: Ben Terry | last post by:
What's the most efficient way to transfer data from a byte to a struct? The struct is rather complex--contains other structs as well as byte members. I've tried to use Marshal.Copy and an IntPtr to my struct address but I get the following error, perhaps due to the byte members of my struct: Cannot take the address or size of a variable of a managed type. Ben
7
6864
by: Joseph Lee | last post by:
Hi All, I am having problem when i am using hashtable to keep an array of bytes value as keys. Take a look at the code snippet below --------------------------------------------------- ASCIIEncoding asciiEncoder = new ASCIIEncoding();
3
2224
by: mraj | last post by:
Hello... I am new to C#. My requirement is that, I will receive over 100s of images from the network to local machine and display these images on an image viewer one by one on mouse scroll. To improve the performance, I want these images to reside on the RAM instead of the hard disk. How do I load the images to the ram and access it to improve my performance. -- Mohan
3
1378
by: Jordan Bowness | last post by:
Can anyone tell me why this doesn't work? It appears to post, but my ..asp page I use to retieve the image pulls up nothing. Here's the posting snippet: ======= begin =======
3
7458
by: Alan | last post by:
Hi, I'm converting a database application from Access 97 to C#/SQL Server. Old database contains some images in OLE fields. I've figured out that there's OLE header preceeding actual image data and dealt with some of the images which were in standard BMP format but most of the images are in some other format which is displayed ok in access application and can be copy/pasted to any image editor but when doubleclicking it doesn't open any...
8
5044
by: den 2005 | last post by:
Hi everybody, I am not sure where to put this in this forum. So, I posted this at several topics. I created a class library that has two public methods Encrypt() and Decrypt(). I reference this dll to a window application. I used DESCryptoServiceProvider Algorithm to encrypt and decrypt then with same Key and IV. But unable to decrypt it back to original text. This project I plan to use all algorithm and Hash. This is Phase One. There is...
17
7239
by: =?Utf-8?B?U2hhcm9u?= | last post by:
Hi Gurus, I need to transfer a jagged array of byte by reference to unmanaged function, The unmanaged code should changed the values of the array, and when the unmanaged function returns I need to show the array data to the end user. Can I do that? How?
0
8428
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
1
8542
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8630
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7362
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6181
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4177
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4343
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2760
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1984
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.