Hi,
How to efficently divide big array into small arrays as showed below?
IN
xxxxxxxxxxxxxx xxxxx xxxxx xxxxx
xxxxxxxxxxxxxx xxxxx xxxxx xxxxx
xxxxxxxxxxxxxx ==>> xxxxx xxxxx xxxxx
xxxxxxxxxxxxxx
xxxxxxxxxxxxxx xxxxx xxxxx xxxxx
xxxxxxxxxxxxxx xxxxx xxxxx xxxxx
xxxxx xxxxx xxxxx
Here is a piece of code I`ve done but it takes a lot of calculations for
bigger bitmaps... Is there any posibility to optimize it to make it faster?
The task of this method is to copy a bitmap into 8x8 square 2d arrays and
return a list of those 2d arrays
public ArrayList podzielNaKwdara ty(Bitmap obraz, char aKolor)
{
ArrayList wartosciRGB = new ArrayList();
for (int l=0;l<wys;l+=8)
{
for (int k=0;k<szer;k+=8 )
{
byte[,] temp = new byte[8,8];
for (int i = 0; i<8; i++)
{
for (int j = 0; j<8; j++)
{
if (i+l>obraz.Heig ht-1 || j+k>obraz.Width-1)
temp[i,j]=0;
else
{
if (aKolor == 'R')
temp[i,j]=m_bitmap.GetPi xel(j+k,i+l).R;
else if (aKolor == 'G')
temp[i,j]=m_bitmap.GetPi xel(j+k,i+l).G;
else if (aKolor == 'B')
temp[i,j]=m_bitmap.GetPi xel(j+k,i+l).G;
}
}
}
wartosciRGB.Add (temp);
}
}
return wartosciRGB;
} 4 2991
Macin <ma****@iv.pl > wrote: How to efficently divide big array into small arrays as showed below?
IN
xxxxxxxxxxxxxx xxxxx xxxxx xxxxx xxxxxxxxxxxxxx xxxxx xxxxx xxxxx xxxxxxxxxxxxxx ==>> xxxxx xxxxx xxxxx xxxxxxxxxxxxxx xxxxxxxxxxxxxx xxxxx xxxxx xxxxx xxxxxxxxxxxxxx xxxxx xxxxx xxxxx xxxxx xxxxx xxxxx
Here is a piece of code I`ve done but it takes a lot of calculations for bigger bitmaps... Is there any posibility to optimize it to make it faster?
Well, the first thing to *try* would be to effectively have three
different methods - one for red, one for green and one for blue. There
seems little point in doing the same comparison for every pixel when
the result will always be the same. The JIT *may* be optimising this
already, but it's worth a try.
--
Jon Skeet - <sk***@pobox.co m> http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
What you mean as JIT?
Uzytkownik "Jon Skeet [C# MVP]" <sk***@pobox.co m> napisal w wiadomosci
news:MP******** *************** *@msnews.micros oft.com... Macin <ma****@iv.pl > wrote: How to efficently divide big array into small arrays as showed below?
IN
xxxxxxxxxxxxxx xxxxx xxxxx xxxxx xxxxxxxxxxxxxx xxxxx xxxxx xxxxx xxxxxxxxxxxxxx ==>> xxxxx xxxxx xxxxx xxxxxxxxxxxxxx xxxxxxxxxxxxxx xxxxx xxxxx xxxxx xxxxxxxxxxxxxx xxxxx xxxxx xxxxx xxxxx xxxxx xxxxx
Here is a piece of code I`ve done but it takes a lot of calculations for bigger bitmaps... Is there any posibility to optimize it to make it faster?
Well, the first thing to *try* would be to effectively have three different methods - one for red, one for green and one for blue. There seems little point in doing the same comparison for every pixel when the result will always be the same. The JIT *may* be optimising this already, but it's worth a try.
-- Jon Skeet - <sk***@pobox.co m> http://www.pobox.com/~skeet If replying to the group, please do not mail me too
Macin wrote: Hi,
How to efficently divide big array into small arrays as showed below?
Here is a piece of code I`ve done but it takes a lot of calculations for bigger bitmaps... Is there any posibility to optimize it to make it faster?
DISCLAIMER: I know nothing about the graphics-libraries of .NET. You can
probably get much better performance by changing representation than by
anything else.
If GetPixel is the only way you can index the Bitmap, then you do need
x*y invocations of it.
For a small thing, you could try to move the branching on aKolor outside
the loop to see if the compiler/JIT is doing the possible code-hoisting
on that.
It would probably be even better to rearrange the code to use just x*y
invocations instead of 3*x*y of GetPixel by making all of the R,G and B
byte[] for one pixel at the same time.
The task of this method is to copy a bitmap into 8x8 square 2d arrays and return a list of those 2d arrays
If interactivity is the problem, you can return an adapter with an IList
interface instead. Passing an adapter will distribute the cost of the
conversion over the access to it, and won't reqire copying.
--
Helge Jensen
mailto:he****** ****@slog.dk
sip:he********* *@slog.dk
-=> Sebastian cover-music: http://ungdomshus.nu <=-
Macin <ma****@iv.pl > wrote: What you mean as JIT?
Just In Time compiler - the thing which converts MSIL (.NET
instructions, basically) into native code at runtime.
--
Jon Skeet - <sk***@pobox.co m> http://www.pobox.com/~skeet
If replying to the group, please do not mail me too This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: VK |
last post by:
A while ago I proposed to update info in the group FAQ section, but I
dropped the discussion using the approach "No matter what color the cat
is as long as it still hounts the mice". Over the last month I had
enough of extra proof that the cat doesn't hount mice anymore in more
and more situations. And the surrent sicretisme among array and hash is
the base for it.
I summarized all points in this article:...
|
by: Frank Pool |
last post by:
Hi,
I have on large threedimensional array
int largeArray;
In a particular function I only need a part of this array
So I'm using a new variable and assign it the follwoing way:
int (*smallArray);
smallArray = &largeArray;
|
by: Paminu |
last post by:
Why make an array of pointers to structs, when it is possible to just make
an array of structs?
I have this struct:
struct test {
int a;
int b;
|
by: reb |
last post by:
Hi,
How do i increase the size of the array without losing the
data of that array in c#?
thanks
|
by: ad |
last post by:
I have a huge sting array, there are about 1000 element in it.
How can I divide the huge array into small ones, and there are one 10
elements in a small one array?
| |
by: per9000 |
last post by:
Hi all,
I have a two-dimensional array of data, f.x int's. We can imagine that
the array is "really large". Now I want the data in it and store this
in a one-dimensional array.
The obvious way to do this is a nested for-loop - but we all know
O(n^2) is bad. So I am looking for something like ArrayList.ToArray(),
or Matlabs A(:).
C#
|
by: Mik0b0 |
last post by:
Hallo everybody,
my problem is: there are two single-dimension arrays, longer and
shorter, every array is organized in ascending order. We need to
build a new array out of two. This is what I wrote:
#include<stdio.h>
#define M 8
#define N 5
main()
{
int big={1,2,5,8,10,23,45,56};
|
by: nembo kid |
last post by:
In the following function, s shouldn't be a pointer costant (array's name)?
So why it is legal its increment? Thanks in advance.
/* Code starts here */
void chartobyte (char *s) {
while (s!=0) {
printf ("%d", *s);
s++;
|
by: Richard Harter |
last post by:
On Fri, 27 Jun 2008 09:28:56 -0700 (PDT), pereges
<Broli00@gmail.comwrote:
There are some obvious questions that should be asked, e.g., is
the contents of your array already sorted as your example
implies. If they are then all you need to do is find the element
at index k = n/2 and then increase k until you find an element
that differs from A. Then k is the number of left children
and n-k is the number of right children. (Fencepost...
|
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...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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...
|
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...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |