Click here to Skip to main content
15,885,244 members
Everything / Bitmap

Bitmap

Bitmap

Great Reads

by #realJSOP
Determine the number of unique colors in an image
by Isaac RF
To create visually engaging apps, displaying images is a must. Learn to display Bitmaps Efficiently on your Android apps, without giving away performance. The post Displaying Bitmaps Efficiently on Android apps appeared first on Isaac RF.
by ToughDev
Revisiting Mario Game Written in Pascal
by V.
Convert FITS file to known image formats and use those images for a "zooming" functionality (image transparency)

Latest Articles

by honey the codewitch
Image Resizer automatically resizes images you drop in a monitored folder based on criteria you give it. It can also change image formats.
by ToughDev
Revisiting Mario Game Written in Pascal
by pdoxtader
Very fast image processing without use of unsafe code
by honey the codewitch
Use an ILI9341 display efficiently from an ESP32 without the Arduino framework. Load JPEGs.

All Articles

Sort by Score

Bitmap 

19 Feb 2011 by #realJSOP
Determine the number of unique colors in an image
24 Aug 2016 by Isaac RF
To create visually engaging apps, displaying images is a must. Learn to display Bitmaps Efficiently on your Android apps, without giving away performance. The post Displaying Bitmaps Efficiently on Android apps appeared first on Isaac RF.
8 Apr 2016 by V.
Convert FITS file to known image formats and use those images for a "zooming" functionality (image transparency)
4 May 2021 by honey the codewitch
Use an ILI9341 display efficiently from an ESP32 without the Arduino framework. Load JPEGs.
21 Feb 2011 by Manfred Rudolf Bihy
Try this CP article for starters: OCR With MODI in Visual C++[^] and here you'll find an open source .NET C++ library: http://www.pixel-technology.com/freeware/tessnet2/[^]Modification:MODI has been deprecated in MS Office 2010. The replacement is OneNote and here is a useful link to...
22 Feb 2015 by Sergey Alexandrovich Kryukov
I was afraid that my suggestion to "think a bit" could possibly offend you a bit, so I probably have to illustrate what this thinking could mean.Suppose you have some bit data, which tells you (forget the "format", it is irrelevant):you have width = 3, height = 2, and pixels data...
27 Dec 2020 by Steffen Ploetz
Step-by-step instructions and source code snippets for inserting a bitmap (or a section of it) into an icon image.
3 May 2011 by CPallini
Why don't you use CImage[^] instead?It can directly load jpeg and png files.
4 May 2011 by Niklas L
The Load()[^] method of CImage, as Pallini suggested, can operate on an IStream instance. You can create such an instance using CreateStreamOnHGlobal()[^] API.
25 Mar 2013 by Sergey Alexandrovich Kryukov
It looks like you are using System.Drawing and System.Windows.Forms. You should always tag the libraries you use for UI and graphics.Look at the Bitmap class. It implements System.IDisposable. It means that, whatever you do, you should eventually call System.IDisposable.Dispose for each...
8 Apr 2013 by Matthew Faithfull
When you say you have a bitmap I guess you have an RGB or BGR bitmap?To do a one off file conversion I would get a copy of IrfanView[^] . In fact I would get it anyway if you don't have it as it is the best tool I know for viewing not quite correctly formatted image data.If you are...
21 Feb 2021 by Steffen Ploetz
My best practice approach to change the image of a toolbar button
17 Apr 2023 by pdoxtader
Very fast image processing without use of unsafe code
15 Mar 2011 by Olivier Levrey
If you want to really improve your image display, then consider using hardware accelerated functions. Use DirectX or OpenGL libraries.Once, I used DirectX and sprites to display a 2D image (and a few more things). I will copy the code that worked for me, but please note I am not a Direct3D...
8 Apr 2011 by Olivier Levrey
Is it really necessary to use an image? Can't you draw directly inside your form?You can use the MouseDown event to get the click position, and Paint event to redraw your line: public partial class Form1 : Form { public Form1() { ...
23 Jul 2012 by enhzflep
I'd have preferred to add this code to a comment, but it's just impractical for so many reasons.Here's the code I had in the project I mentioned earlier. It does seem a bit funky now, some 4 1/2 years on - I think saveBMPfloat would be the easiest/quickest to modify. Just snip/replace the...
26 Jul 2012 by Dave Kreskowiak
It's not entirely clear what you're doing, so are you saying that you're writing this text to an image and then printing the image??Yeah, that's going to severely screw up any aliasing you do. Why??Because the image that you're drawing on is 96 DPI and when you print that image on...
27 Aug 2013 by huyletran
Create a new bitmap by combining many bitmaps.
4 Apr 2014 by KarstenK
you must transform with the right HWNDHWND hParent = GetParent(hwnd);ClientToScreen( hwnd, &ptTreeUL );ClientToScreen( hwnd, &ptTreeLR );//dont write such code ;-)ReleaseDC( GetParent(hwnd), pDC );tip: create the bitmap globally once to improve performance
9 Jun 2014 by Sergey Alexandrovich Kryukov
What is unclear in this error message? It is quite straightforward. You are doing wrong thing: you cannot lock bits on the same Bitmap b twice and work with bmpData and bmpData2 at the same time. And, in practice, it's never needed. You can create bitmap data once, do what you need to do with...
5 Aug 2014 by Sergey Alexandrovich Kryukov
I answered to similar questions several times. I advise to use AForge.NET, its blob recognition. I successfully used it and was pleasantly surprised with performance and quality of the results. Please see my answers:URGENT PLZ - image Processing in c#[^],image processing using Aforge.net >>...
21 Oct 2014 by DamithSL
Add: using Windows.UI.Xaml.Media.Imaging;Reference: Loading and processing bitmaps[^]
12 Dec 2014 by Maciej Los
Have a look here: Merging Images in .NET[^]More, you can find here: SearchBox[^]
21 Feb 2015 by nv3
Just exchanging width and height will not rotate the image. You also need to rotate the bitmap data pixel by pixel. That requires quite a bit of buffer handling and data shoveling. For an example how to do it, look here: Add fast user-extensible image processing support to CBitmap[^]
28 Feb 2015 by Sergey Alexandrovich Kryukov
As in many other graphics rendering system, your code is the handler of some event invoked when the drawing is required. You hard-coded the bitmap coordinates, so what would you expect. You have to make these coordinate depending on some field(s) of declaring class, say, bitmapX, bitmapY. You...
12 Oct 2015 by bling
I do not know if this will fix all your problems but, try replacing this: array_1D[offset + i+0] = arrayB_2D[j][counter++]; array_1D[offset + i+1] = arrayG_2D[j][counter++]; array_1D[offset + i+2] = arrayR_2D[j][counter++];... with this ... array_1D[offset + i+0] =...
4 Nov 2015 by bling
Your paint handler looks strange to me. private void Form1_Paint(object sender, PaintEventArgs e) { gDisplay.DrawImage(bitmap, new Point(0, 0)); }Try this:private void Form1_Paint(object sender, PaintEventArgs e){ ...
27 Mar 2016 by Sascha Lefèvre
Quote:Others say that although this is important, they don't actually do much in terms of memory issues.When not using using-statements the CLR eventually comes around to cleaning up those objects but there's no guarantee on when this will happen. So it can lead to inconsistent behaviour. When...
30 Apr 2016 by Richard MacCutchan
See also Wallpaper Changer[^].
13 Oct 2018 by Steffen Ploetz
How to use GL's pixel buffer object (PBO) to copy one texture to another
17 Apr 2021 by honey the codewitch
GFX IoT graphics library part 2 - device independent bitmaps
3 Aug 2011 by nervous_cat
Am having some trouble that i'm recieving an input from wpf that is of type Windows.Media.DrawingImage and I need to convert it to either windows.media.ImageSource or to windows.media.BitmapImage inorder for me to convert those into System.drawing.bitmap or System.drawing.image.I have...
6 Aug 2011 by Sergey Alexandrovich Kryukov
There is one pretty brutal way of doing it: write a bitmap to MemoryStream using one library and read it using another one; this method works in both directions.If you needed to go from System.Drawing to System.Windows.Media, the solution would be in using System.Windows.Interop.Imaging,...
13 Sep 2011 by OriginalGriff
DrawToBitmap only draws from the TLHC of the source control, as it assumes that the whole control (in this case, probably an entire form) will be required. If you want just a portion, then you need to draw the whole control into a suitable bitmap, then draw a portion of that image into a new...
18 Sep 2011 by Sergey Alexandrovich Kryukov
This is quite possible but not quite trivial. EMF file is not exactly a container of vector graphical primitive. It is rather a sequence of events and can be "played", much like a video, to get displayed. You can find the EMF's elements by using the method...
22 Nov 2011 by JackDingler
You're sharing the single 'pos' variable among all of your threads.You'll get random values, as each thread is sharing the same location and writing and reading from it. Who knows what value it will have by the time the thread gets to the next line? And even in that line, the value can...
16 Jul 2012 by Sergey Alexandrovich Kryukov
As I can see, you manipulate the bitmap and then completely forget the result, replacing it with a brand new instance of a bitmap (a line of code with new Bitmap(&hellip)).Besides, the name "m_PicBoxes" suggests that you use the class System.Windows.Forms.PictureBox, which is not a very good...
24 Jul 2012 by nv3
In my opinion you are making things more complicated than they have to be. Here is the code that allocates your 2-dimensional array: int** array_ptr; array_ptr = new int * [1000]; // 1000 row pointers for(int i = 0; i
31 Jul 2012 by Christian Graus
The only real way to improve print quality is to create a larger bitmap that is finer quality. GIGO.graphics.FromImage(bitmap) creates an exact copy, though, you should not lose quality doing that.
6 Sep 2012 by Amund Gjersøe
According to Microsoft you should be able to use BmpBitmapDecoder (or the decoder of choice). I've tested, and it worked:Stream bmpStream = new System.IO.FileStream("smiley.bmp", FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite);BmpBitmapDecoder bmpDecoder = new...
28 Sep 2012 by Richard MacCutchan
A PDF file is not a simple byte array, it is a structured file consisting of different content elements. Go to the Adobe website and get a copy of the PDF documentation for further information.
21 Oct 2012 by Jackie00100
I found this class recent extending the graphics class, i changed it a little, and it does everything i could ask for!using System;using System.Drawing;using System.Runtime.InteropServices;using System.Windows.Forms;using System.Drawing.Imaging;using System.Text;public static...
11 Jan 2013 by Jibesh
Check whether the property you are looking is valid for the image. If PropertyItems collection is empty you will end up with this error. read more here[^]
13 Feb 2013 by TRK3
It's patently false that the only possible exception is FileNotFound. The file could certainly existed but have an exclusive lock on it -- in which case the constructor would have to fail, but not because the file wasn't found.Documentation says:"The file remains locked until the Bitmap...
19 Mar 2013 by Dave Kreskowiak
You don't.Reducing the number of pixels will ALWAYS reduce the image size. With a "reduced" number of pixels, you get the illusion of a larger image only when it's displayed by scaling up a smaller image fit a display area larger than the image. This results in a fuzzier display and a...
23 Nov 2013 by Richard MacCutchan
Iterate through the bitmap making a list of every pixel's colour, not forgetting to ignore duplicates. Then sort the list into whatever order you prefer, e.g. reds, greens, blues etc. Then go through the list and draw a shape in the window for each colour. See the GetPixel method[^] for further...
10 May 2014 by AlwaysLearningNewStuff
I have a bitmap which background needs to be replaced with part of another bitmap. Everything works fine until I enable ClearFont on my WindowsXP.In order to explain my problem better, let us label first bitmap as bmpDestination and second as bmpSource.Here[^] is how the bmpSource looks...
10 May 2014 by leon de boer
I added this to your previous post it got messy so you probably missed it.There are ways around it but they are all slow and give different results which you have to choose between. There is no perfect solution because it is a bug or over-sight in windows Cleartype implementation.I...
11 May 2014 by leon de boer
I have studied carefully the code from your previous answer and managed to handle WM_WINDOWPOSCHANGED properly for multiple windows but I can not handle slight flickering.What is causing the flicker is the way the listbox draws each item you need to do you own drawing to solve the problem...
11 May 2014 by leon de boer
Oh I forgot I further improved your redraw and made it compliant to handling WM_PRINTCLIENT itself.case WM_PAINT: { // usual stuff PAINTSTRUCT ps; HDC hdc = BeginPaint( hwnd, &ps ); // Simply get printclient to paint ::SendMessage(hwnd, WM_PRINTCLIENT,(WPARAM)...
7 Jun 2014 by Sergey Alexandrovich Kryukov
Please see my comment to the question.One of the way to perform necessary calculations is using System.Drawing, more exactly:http://msdn.microsoft.com/en-us/library/system.drawing.bitmap.lockbits.aspx[^].There are some code samples on the pages of each of these methods, just to...
9 Jun 2014 by Sergey Alexandrovich Kryukov
It's not clear what do you miss in this documentation. Pay attention: the method System.Windows.Media.Imaging.RenderTargetBitmap.Render takes the instance of System.Windows.Media.Visual as a parameter. And your class ModelBeamSectionNamesInPlan is UIElement and, consequently,...
25 Jun 2014 by OriginalGriff
Start here: Bmp.Save(str1 & "\" & str2, Imaging.ImageFormat.Jpeg)Don't use Imaging.ImageFormat.Jpeg - it's a lossy compression technique and that means that it "throws away" information ion order to save space every single time you save it. The chance are, this is the source of your...
21 Jul 2014 by Sergey Alexandrovich Kryukov
Not only using GetPixel is prohibitively slow, it's just no serious. If you don't know how to develop image recognition by yourself (this is not easy at all), you can use one of the open-source libraries. I would recommend native .NET library...
13 Dec 2014 by Member 10756761
i need a solution in C# to merge two separate images without merging a line between them at they merge..Problem picjust merg 2 images, a line show b/w them because of color difference, i want to disappear that line,CODE: private Bitmap Merge_Images(Bitmap bmp_1, Bitmap...
12 Dec 2014 by Thomas Daniels
This can be done using the Graphics class in the System.Drawing namespace. First, you have load the two images you want to merge. Then, you create a new empty Bitmap where the width is the sum of the two widths of the loaded images, and the height is the maximum height of those images. After...
13 Dec 2014 by BillWoodruff
Whether two images can be merged (composited) in a way that no unusual boundary (artifacts) will appear in the merged image, depends entirely on the images you are attempting to merge !And, I propose to you that ... unless you are in the fortunate position of having images with the same...
23 Feb 2015 by KarstenK
as barneyman wrote rotating the bmp in memory is the right solution.Read the outstanding article CXImage which provides some tons of features and also rotating code. In the sources you will find some code for rotating images.
25 Feb 2015 by CPallini
You have to take into account that bitmaps have rows aligned on 32 bits (i.e four bytes) boundaries (they are padded). The original bitmap, having width 800 doesn't need padding (hence is size is exactly 1646454 bytes) while the rotated image needs it (686 % 4 is non-zero), that is you need to...
25 Feb 2015 by Andreas Gieriet
Rotating a matrix by 90 degree is done by the following transformation of zero-based indices:A = N x M original matrixB = M x N transformed matrix (i.e. rotated by +90 degree)A[i,j] -> B[M-j-1,i]So, you read the data into the original matrix in memory, create a transformation matrix in...
20 Oct 2015 by Member 11999641
hi Members,I have ajax tab container that contains many tabs. I want to loop through each tab and draw the tab panel content to bitmap.This is my current codes:foreach (object obj in container.Controls) { if (obj is AjaxControlToolkit.TabPanel)...
2 Nov 2015 by Suvendu Shekhar Giri
You can convert any DOM objects to image.Check this article for details and demoConvert (Export) HTML DIV or Table to Image using HTML Canvas in ASP.Net using C# and VB.Net[^]Hope, it helps :)
5 Jan 2016 by Dave Kreskowiak
I haven't touched C++ in about 5 years and I've never even heard of Embarcadero, but... it looks like your cast is being applied to the wrong item. Shouldn't it be something like:Sbyte = (TRBGTriple *)(Source->scanline[y]);
6 Jul 2016 by Midi_Mick
Firstly, there are a few things to note in your report of the bitmap attributes: 1. Stride is usually reported in bytes, not pixels. 2. Each pixel is 4 bytes (32 bits). 3. This means that your offset or padding will be 0 (2048 bytes - 512*4 bytes).Each row of your bitmap...
24 Nov 2016 by F-ES Sitecore
You only include the namespace in the "using", not the class nameusing System.DrawingIf you're struggling to even create a class you're really going to struggle doing anything more advanced. I'd get a book on c# and start learning the basics before moving on to anything else.
16 Jan 2017 by KarstenK
Create and populate the bitmap and the other stuff once at program start. These operations are "expensive" so do them as less as possible.//Gobal bitmapBITMAP bm = {0};// init with zerosvoid drawlineOverlay(HWND m_hwndApp){ //run code once if( bm.bmWidth == 0 ) { // set...
31 Oct 2018 by F-ES Sitecore
You're missing some parenthesis. newImage = ((Bitmap)image).Clone(sRec,PixelFormat.Format16bppArgb1555); In your original code "(Bitmap)image.Clone" You are calling the Clone method on whatever type image is, you're not calling it on image cast to Bitmap. By adding the parenthesis you are...
18 Dec 2018 by OriginalGriff
Repost, again. When you asked this question yesterday: Any ideas for scanning multiple choices answers?[^] I told you that the answer hadn't changed since the day before: How to crop an image in an appropriate way, C#?[^] I repeat: the answer doesn't change just because you don't like it.
5 Feb 2020 by OriginalGriff
Look at the pixels (this may help: Bitmap.GetPixel(Int32, Int32) Method (System.Drawing) | Microsoft Docs[^] ) and compare them to Color.Black What did you expect us to tell you to do?
20 May 2022 by Richard MacCutchan
See the Remarks section at Bitmap.LockBits Method (System.Drawing) | Microsoft Docs[^].
28 May 2019 by MinYoung Lee
I've been trying to develop Remote Desktop Program in C# and I want to make the BYTE size of my Image smaller. Here is my attempt below so far. // int w = Screen.PrimaryScreen.Bounds.Width; int h = Screen.PrimaryScreen.Bounds.Height; ...
9 Feb 2024 by honey the codewitch
Image Resizer automatically resizes images you drop in a monitored folder based on criteria you give it. It can also change image formats.
19 Feb 2011 by a_pess
I think we may check if the color is repeated or not, any how this another alternative but in VB.NetPublic Shared Function GetImageColorsCount(ByVal bitmap As Bitmap) As Integer Dim ColorList As New System.Collections.Generic.List(Of Integer) Dim clr As Integer For...
21 Feb 2011 by Member 7692532
What I'm trying to do is to recognize words from a BMP or preferably directly on screen. I honestly have no idea where to start with this. The best thing I can come up with is to have a preset image and compare it to where it should be on the screen, but that would require a lot of CPU and quite...
14 Mar 2011 by kagelind
Hi I am trying to stretch a bitmapas fast as possible. I need to stretch 60 bitmaps per second. I am using StretchBltBits but when I use HALFTONE BltMode I only get 24-25 frames per second.The bitmap can be 16bpp, 24bppor and 32bpp 1024x576.is ther a faster way to strech the bitmap...
26 Mar 2011 by nbd09
I have written some code to draw some lines etc in a device context and bitmap in ondraw class.I can save that bitmap using cimage but I want to access that bitmap from other button or class.The bitmap is not accessible from anywhere other than the ondraw class. I have also tried taking the...
3 May 2011 by quyps
Hi all,In my project, i receive an input as a memory block which is merely binary data read from an image file (.jpeg, .png).How can i create a CBitmap object from that?quyps,
3 May 2011 by Kozlov_Sergey
Create CBitmap with given dimentions, then use functionDWORD SetBitmapBits( DWORD dwCount, const void* lpBits);
4 May 2011 by quyps
Thanks alot! You are all right, it's the solution. I also found one here An MFC picture control to dynamically show pictures in a dialog[^]
23 May 2011 by Sergey Alexandrovich Kryukov
How to do it totally depends on the data presentation of your image being edited. If this is just a bitmap and not a collection of Z-ordered bit-mapped objects (as in mature editors like GIMP and Photoshop), you have only two possibilities. Let's assume you render all your graphics on a bitmap...
24 May 2011 by 94HellGate
i found another solutioncreate a texture brush based on the texture you are drawing with opacity (using a ColorMatrix) and set the graphics option CompositingMode to SourceCopy and draw your circle or whatever.some code:float[][] matrixItems ={ new...
17 Jun 2011 by Keith Barrow
You should take a look at this thread on StackOverflow:http://stackoverflow.com/questions/384931/how-do-i-get-an-icon-from-a-png-image[^]Personally, I'd convert the png to ico (the thread has a link to at tool to do that) as it is the path of least resistance, but it is always good to have...
10 Jul 2011 by Bob Namenottaken
Using SetBitmapBits is confusing me. Is its sole purpose to transfer my array of pixel info to a buffer owned by the handle "HBITMAP" ?Is there a way to know where this buffer is located and write to it directly?Seems like a waste of time to draw on your own array and then perform a huge...
10 Jul 2011 by Emilio Garavaglia
GDI object's internal data don't belong to your process but to the GDI subsystem. You cannot read/write to them directly because there is a "process boundary" in between (they can even be on another machine!).The memory itself can be moved around by the GDI functions, without your program...
12 Aug 2011 by fasan21
HiThis seems to be quite a tricky one.I am uploading images into a database using C# 4.I serialize them, then convert them to byte[] so that they can be loaded into a "Image" type field.This works great.If I convert back from byte[] to string and save the image, it saves...
12 Aug 2011 by #realJSOP
To convert a byte array to a BitmapImage object:MemoryStream stream = new MemoryStream(bytearray);BitmapImage image = new BitmapImage();image.SetSource(stream);At this point, you can set your object's Source property to your new BitmapImage object.myImage.Source = image;
13 Sep 2011 by AmirAli1374
Bitmap ax = new Bitmap(300, 300); Rectangle rc = new Rectangle(0, 0, 300, 300); this.DrawToBitmap(ax, rc); pictureBox1.Image = ax;after running this code we have an image of part of form (from point(0,0) to point(300,300)) but i want an...
14 Sep 2011 by BobJanova
pictureBox1 must be a control on the form. Try moving the picture box to an origin of (300, 300).
14 Sep 2011 by merkousha
hi,i worked on a project that in a step we must find a first character's position in a first line of a texts that we store it in a emf file .also we have a another problem that , some times our text line may have a Equation and this Equation may have a anormal height . this means that , the...
21 Sep 2011 by Member 4160511
Hi everyone,is it possible too capture a Bitmap from a hidden WebbrowserControl?webBrowser1.DrawToBitmap(b, new Rectangle(0, 0, 600, 400)); doesn't work.This will only capture the control itself(scrollbars) not the children's so the content area is still white :-(any...
22 Sep 2011 by DaveAuld
Here's an example;http://www.geekpedia.com/code140_Taking-Website-Screenshots-With-The-WebBrowser-Control.html[^]
28 Sep 2011 by fasan21
I used normal deserializing in my webservice of my asp app.
5 Oct 2011 by genisyssoftware
In this code example: public void convertBmp(string imagepath){ Bitmap image = new Bitmap(imagepath); for (int y = 0; y
5 Oct 2011 by Sergey Alexandrovich Kryukov
Oh! First of all, forget about GetPixel/SetPixel and never recall it again. :-) The performance is not acceptable. Instead, use System.Drawing.Bitmap.LockBits. You will find a code sample here: http://msdn.microsoft.com/en-us/library/5ey6h79d.aspx[^].You will need two bitmaps as your target...
20 Oct 2011 by difemen
Hi,sorry my braziliam english.im trying to do a little program that create a 2d array that returns 1 if have color or 0 if no but ever return 0. can anybody help me? i used a listbox to see the returnsBitmap newBitmap = new Bitmap(img.Width, img.Height); byte[,] buffer = new...
20 Oct 2011 by André Kraak
The Bitmap[^] you are creating with Bitmap newBitmap = new Bitmap(img.Width, img.Height); has a default black background. So all the values in your 2D array will be 0.Before you start checking for colour you will need to place a colour picture in your bitmap.Notes:1 - Remove...
21 Nov 2011 by Peter Kottas
Hello world! I am currently trying to develop a good way for bitmap-matrix , matrix - bitmap operation. I used lockbits on bitmap and things were pretty fast. But recently i learned about OPENMP and it got me thinking whether it is possible to use it on IO operation like this. When i tried "omp...
22 Nov 2011 by Peter Kottas
Thanks , you cleared it very good. I am new to unmanaged code to but it seem there is a little error in your fix ... just in case somebody reads this i believe it should be like. But the idea of increments and line pointers is brilliant thanks a lot.#pragma omp parallel for private(i)for...
22 Nov 2011 by Peter Kottas
thanks for the typecasting hint. about that dereferencing ... float * arrptr=mat[i]; for(int j=0;j