473,804 Members | 3,790 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

bitmap array

Hi

I create bitmap array :

Graphics::TBitm ap ***bitmap;

bitmap = new Graphics::TBitm ap**[x];
for (int s=0;s<x;s++)
{
bitmap[s] = new Graphics::TBitm ap*[y];
for (int u=0;u<y;u++)
bitmap[s][u] = new Graphics::TBitm ap;
}

How can i delete this array ?

for (int s=0;s<x;s++)
{
for (int u=0;u<y;u++)
delete bitmap[s][u];
delete bitmap[s];
}

or I have to use "delete[]" command?

regards

Sebastor


Jan 27 '06 #1
3 4858
Sebastor wrote:
I create bitmap array :

Graphics::TBitm ap ***bitmap;

bitmap = new Graphics::TBitm ap**[x];
for (int s=0;s<x;s++)
{
bitmap[s] = new Graphics::TBitm ap*[y];
for (int u=0;u<y;u++)
bitmap[s][u] = new Graphics::TBitm ap;
Since individual element is created using "regular" 'new'...
}

How can i delete this array ?

for (int s=0;s<x;s++)
{
for (int u=0;u<y;u++)
delete bitmap[s][u];
You should use "regular" 'delete'
delete bitmap[s];
But since 'bitmap[s]' was created using 'new[]', you must use 'delete[]':

delete[] bitmap[s];
}
And you forgot to delete the 'bitmap' itself here...

or I have to use "delete[]" command?


Depends. See above.

V
Jan 27 '06 #2
On Fri, 27 Jan 2006 22:58:57 +0100, "Sebastor" <br********@one t.pl>
wrote:
Hi

I create bitmap array :

Graphics::TBit map ***bitmap;

bitmap = new Graphics::TBitm ap**[x];
for (int s=0;s<x;s++)
{
bitmap[s] = new Graphics::TBitm ap*[y];
for (int u=0;u<y;u++)
bitmap[s][u] = new Graphics::TBitm ap;
}

How can i delete this array ?

for (int s=0;s<x;s++)
{
for (int u=0;u<y;u++)
delete bitmap[s][u];
delete bitmap[s];
}

or I have to use "delete[]" command?

regards

Sebastor


The rule is, use delete[] wherever you used new[]. You used new[]
sometimes, and new at other times. Don't become confused by the array
subscripts, which have nothing to do with delete[].

--
Bob Hairgrove
No**********@Ho me.com
Jan 27 '06 #3
In article <dr**********@o pal.icpnet.pl>,
"Sebastor" <br********@one t.pl> wrote:
Hi

I create bitmap array :

Graphics::TBitm ap ***bitmap;

bitmap = new Graphics::TBitm ap**[x];
for (int s=0;s<x;s++)
{
bitmap[s] = new Graphics::TBitm ap*[y];
for (int u=0;u<y;u++)
bitmap[s][u] = new Graphics::TBitm ap;
}

How can i delete this array ?

for (int s=0;s<x;s++)
{
for (int u=0;u<y;u++)
delete bitmap[s][u];
delete bitmap[s];
}

or I have to use "delete[]" command?


This is a great example why you should use the standard containers...

template < typename T >
class Array {
int _x;
std::deque< T > _array;
public:
Array( int x, int y ): _x( x ), _array( x * y ) { }
const T& operator()( int x, int y ) const {
return _array[ x * _x + y ];
}
T& operator()( int x, int y ) {
return _array[ x * _x + y ];
}
};

Now create your array:

Array< Graphics::TBitm ap > bitmap( x, y );

You get proper destruction as well as copy semantics for free.
Jan 28 '06 #4

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

Similar topics

0
3610
by: CroDude | last post by:
Hi all! I have problems when writting bitmap to a byte array and after reading it back form byte to Bitmap object. What I do is this: First I throw Bitmap to a memory-stream and then I write it into byte from a stream. Exception (System.ArgumentException: Invalid parameter used) occurs when reading from byte over a memory-stream back to the Bitmap object. Please help, I'm really stuck here! Here's the code I use (Sorry for a long...
1
10618
by: Sharon | last post by:
I have 2 questions that are just the opposite to one another: (1) I need to read an image file (like bitmap, jpeg etc.) and to save only its data, I need to save his data in a raw data format, meaning; I don't want to save the image header, only the pixels data. the raw data should be saved in a byte array. The direct way is to do a loop over the image pixels and to copy pixel by pixel to the byte array. I'm looking for another way to...
6
1813
by: Crirus | last post by:
Strange behaviour: I havea bitmap that I draw and add to an array of bitmaps... Do I have to create a bitmap using New every time? I tried to draw the bitmap in a for loop alike this: Dim mask As Image = getPicture("mask") Dim tempMask As Bitmap=New Bitmap(tile.Width, tile.Height) Dim grMask As Graphics= Graphics.FromImage(tempMask) Dim x As Integer
5
7380
by: Lance | last post by:
I need to create a Drawing.Bitmap from an array of integer values. My current technique creates a bitmap that eventually becomes corrupt (i.e., the bitmap's pixels change to a different color after a while). Can somebody please tell me what I'm doing wrong? Here is a sample: Public Shared Function CreateBitmapFromArray( _ ByVal width As Integer, _ ByVal height As Integer, _ ByVal pixelFormat As Drawing.Imaging.PixelFormat, _
10
3314
by: pcnerd | last post by:
I'm a VB.NET newbie. I've created a program that plots pixels at random on the form. I have a 19" LCD monitor with a resolution set to 1280 by 1024. If you do the math, that means that there are over 1.3 million pixels. In one version of the program, the pixels start plotting at the upper-left & go down the form from top to bottom & left to right. In another version, the pixels are plotted at random. I have a 2.4 GHZ Athlon 64 with 1...
3
3121
by: Iwanow | last post by:
Hello! My goal is to develop a program that opens a bitmap, copies its pixels to an ArrayList in order to perform some complex calculations (edge detection, Hough transform etc.), and save resulting image back in some other bitmap. It works pretty fast, except for stages of coping pixels between bitmap (object of type Bitmap) and the ArrayList. I'm using the trivial
2
2361
by: =?Utf-8?B?UHJ6ZW1v?= | last post by:
Hi, I would like to have a web service method sending a bitmap image. But code like do not work: <WebMethod()_ Public Function GetBitmap() As Drawing.Bitmap Dim a As New Drawing.Bitmap("1.bmp", False) Return a End Function
5
9099
by: stef | last post by:
hello I can find all kind of procedures to convert an array to a bitmap (wxPython, PIL), but I can't find the reverse, either - convert a bitmap to an array or - read a bitmap file to an array
20
7019
by: Joe Duchtel | last post by:
Hello - I have the following code to get a bitmap from the clipboard and to save it to a *.png file ... Dim lData As IDataObject = Clipboard.GetDataObject() If lData.GetDataPresent(DataFormats.Bitmap) Then Dim lPictureBox As New PictureBox
0
9705
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...
0
9576
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,...
0
10568
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10311
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
10074
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
9138
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
7613
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
6847
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5516
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...

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.