Click here to Skip to main content
15,891,529 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 Updated

Bitmap 

19 Feb 2011 by #realJSOP
Determine the number of unique colors in an image
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;
1 Dec 2011 by #realJSOP
You might want to look into using the FreeImage library or the ImageMajik library. I'm pretty sure one or both of them can handle images that size (GDI+ is the reason you can't do it in native .Net).Google is your friend.
22 Apr 2014 by 123456789igor
Hello, I'm use AForge framework and i get image capture from webcam, then i want to send this image from server to client. But the problem consists of that i get the bitmap variable, which gets in event, after executing method AcceptTcpClientAsync and bitmap variable is null. How to get image...
12 Apr 2012 by 45YG
I am trying to display a emf image in WPF application.I have succeeded to use the following two methods convert it,but both of they are so slow.I want get a fast way? Who can help me!! thanks....Method one :using (Stream stream = new MemoryStream(bytes)) { ...
23 May 2011 by 94HellGate
whats the best way to make a simple erase brush / pen to erase parts of a transparency bitmap (with erase opacity)?
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...
26 Jun 2015 by _Q12_
Bitmap img;//outside current method. private void Form1_Load(object sender, EventArgs e) { pictureBox1.SizeMode = PictureBoxSizeMode.Zoom; img = new Bitmap(file.FullName); if (img.Height >=...
26 Jun 2015 by _Q12_
it seem i got a stroke of geniality...:)i used the three rule.And is working perfectly... yuhoo. uc.pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage; img = new Bitmap(item.FullName); uc.pictureBox1.Image = img; ...
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...
26 Nov 2011 by Abhinav S
This[^] might help you.
16 Mar 2014 by Abhinav S
Check the folder permissions where you are saving the file.You should have permissions to save the file.In addition, ensure that the file does not already exist and is open in another program.
16 Apr 2014 by Abinash_Sahoo
Here is an example which shows how to configure a Web service to handle the larger amount of datahttp://msdn.microsoft.com/en-us/library/aa528822.aspx[^]
18 Feb 2014 by Adi5555
i am making a video stegnaography project in which i got the clone of the selected frames from the video and then i have to replace these embedded frames with the real frames in the video...i have used the avifile library so far and i use the cut function in the avi library...the cut function...
20 Aug 2016 by Afzaal Ahmad Zeeshan
This generic exception is the worst exception that one can get while working with graphics objects. It just simply doesn't provide anything at all. Quote:An unhandled exception of type 'System.Runtime.InteropServices.ExternalException' occurred in System.Drawing.dll Additional information: A...
2 Apr 2012 by ajaiisnow
Hai, my requirement is to draw a line over a bitmap loaded into memory. i am working in WinCE. The code i wrote is like this, HGDIOBJ hPrevObj = 0; HGDIOBJ hPrevObj1 = 0; BOOL bStat = 0; dwError = ::GetLastError(); hDCMem =...
21 Feb 2015 by Alexis i
#include#include
23 Feb 2015 by Alexis i
i'm trying to rotate a 686*800 bmp photo 90 degrees.here's my code, it corrupts the file!#include#includeusing namespace std;int main(){ fstream flower("flower.bmp", ios::in | ios::out | ios::binary); flower.seekg(18,ios::beg); char...
25 Feb 2015 by Alexis i
here's my code, it corrupts the photo i donno why!** its a 24-bit bitmap **#include#includeusing namespace std;int main(){ fstream flower("flower.bmp", ios::in | ios::out | ios::binary); //declaring an array which holds data bytes belong to 800*686...
28 Feb 2015 by Allwin456
I have this bitmap drawn on android canvas - protected void onDraw(Canvas canvas) { super.onDraw(canvas); Bitmap myBitmap = BitmapFactory.decodeResource(getResources(), R.drawable.pic1); canvas.drawBitmap(myBitmap, 0, 0, null); ...
4 Apr 2014 by AlwaysLearningNewStuff
I have a dialog box with a bitmap as background.I am trying to create transparent treeview so I need to grab the underlying bitmap from treeview's WM_PAINT handler, but I do not know how to do this.I assume that I will need ScreenToClient and ClientToScreen APIs, but I do not know how to...
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...
4 Jan 2018 by Amedora Ahmed
I am reading binary data image from a serial port device how can i write it to a black and white image file. The project is a bill counting machine which solution. the device scans images of serial number of bill counted including the data counter Below is the data returned from the device as...
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...
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...
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 Feb 2011 by Andrew Rissing
Just a few minor improvements to readability and such...The catch/throw isn't needed here, since you are just throwing it without doing anything in the catch block. A try/finally could have been used on its own.The try/finally isn't necessary because a using statement can achieve the same...
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...
28 May 2019 by AntonioLeonardo
The imagem compression follow another objects and features that different of trivial files; image compreession has properties to equalize the compression. Like code bellow, the compression act on Quality property: static byte[] CompressByImageAlg(int jpegQuality, byte[] data) {...
4 Oct 2016 by Arun Chandrasekhara Pillai
Create a screen recorder using C#
20 Apr 2020 by AskalotLearnalot
I am using Bitmap to water mark tif image files after it reach file number 440 the image size increases which results in a small text watermark. My method is designed to process large amount of files, it also checks if the image is colored or not...
2 Dec 2014 by Azeem Tariq
i have an issue. actually i have cut down an image into pieces and after changing colors of the pieces i save them on server now i assemble these pieces on web page to make full image now i want to save full image on server. i have prices now and want to make full image from them. is it possible...
21 Oct 2014 by B. Clay Shannon
I need to use a Bitmap class in my app, but this code: public class PushpinMetadata { public string FileName { get; set; } public DateTime DateTimeTaken { get; set; } public Bitmap thumbnail { get; set; } }...fails because...
21 Oct 2014 by B. Clay Shannon
Aha, voila, and Eureka - it's apparently BitmapImage that I need.
25 Feb 2015 by BacchusBeale
If you are writing code for windows you can use .Net library to help you:Rotate image[^] then it will work for any image.As already mentioned it is not good to use hard-coded values, they should be parameters to your method.Also using a Hex Editor can help you see what the file really...
3 Dec 2013 by Bahram Ettehadieh
Use this: graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias; graphics.DrawString(... worked for me
24 Jun 2014 by Balav4
Hi Try this MemoryStream Ms = new MemoryStream(); System.Drawing.Bitmap ObjBitmap = null; ObjBitmap = //Load your Image; ObjBitmap.Save(Ms, System.Drawing.Imaging.ImageFormat.Bmp); ...
1 Oct 2012 by Bernhard Hiller
You need the Graphics.DrawString method. You can get the Graphics object by Graphics.FromImage. And then draw all the text your self...
16 Jul 2012 by bikekowal
Hi all,I have a following problem. I want to build a application processing images from a camera in real time. The problem is that I cannot get to the bitmap data correctly. The following piece of code is running without errors but the problem is that the images don't change. The code...
29 Aug 2012 by BillW33
If you are using EMGU, as it says in your tag, you can call cvSmooth. I have discussed the parameters below and shown an example of the call.Image inputImage;//Set inputImage to whatever image you want to smoothImage smoothedImage = new Image
23 Nov 2013 by BillWoodruff
On November 13, this year, I posted a very complete code example for analyzing all the colors in a bitmap: you could easily adapt that code to your goal: [^].
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...
9 Oct 2015 by binaryoffset
Hello. I am currently trying to extract R, G, B values from a 256 colour bitmap image (using for testing purposes a fixed width of 152 and height 150). I have checked using BITMAPINFOHEADER and BITMAPFILEHEADER that the offset is 1078 and bytes per pixel is 1.The image data is initially...
12 Oct 2015 by binaryoffset
Hello all.I am currently working on imaging processing using arrays to store R,G,B values from a 24 bit BITMAP image of width 120 and height 100 pixels.Visual Studio 2010 is being used. I have currently extracted the individual R,G,B values into three separate2D arrays from the 24 bit...
20 Aug 2016 by binaryoffset
Hello. I am trying to copy and save the contents of a Bitmap class image to a *.bmp file but currently receive Unhandled Exceptions during run-time of the console program. I would be grateful to learn where the error lies and how to fix this program. Thank you.Below is the main part of the...
22 Dec 2014 by bling
You need to assign bitmapData to the return value for Lockbits. BitmapData bitmapData = bmp.LockBits( &rect, ImageLockModeWrite, PixelFormat32bppARGB, &bitmapData);
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
Turn on double buffering on the form.https://msdn.microsoft.com/en-us/library/3t7htc9c%28v=vs.110%29.aspx[^]
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){ ...
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...
14 Sep 2011 by BobJanova
pictureBox1 must be a control on the form. Try moving the picture box to an origin of (300, 300).
2 Oct 2012 by BobJanova
There are two options here:You can write the text to a RichTextBox and then screen capture it with Control.DrawToBitmap[^]. You probably need to post-process the Bitmap you get to sort out the transparency.You can write a miniature RTF (or HTML or other tagging system; RTF is pretty...
30 Apr 2016 by ByeByeByeByeBye
how would I change the wallpaper with C# back to a known path of a bitmap or remove the wallpaper for good? Is there any command for it. A SendKeys Combo would be fine.Can't access my wallpaper settings manually any longer, it's been greyed out all options and I have a strange bitcoin...
14 Jan 2015 by Carpi_1968
I'm working on a small project, where I need a DataGrid where a column contains an imageButton as a UserControl.What I'm struggling with is how to bind the image source to the image in my UserControl.I stripped everything down to only have this function left and I guess I'm just missing...
26 Nov 2011 by chieto
Anyone here know how to compare 2 images. . and then show how many percent from before and after image captured. thanks in advance.
26 Nov 2011 by chieto
Thanks for your reply. . but what algorithm im going to use?Thanks
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.
27 Aug 2012 by Christian Graus
This[^] is a wikipedia entry on the BMP file format, specifically, the header.
28 Aug 2012 by Christian Graus
We have no idea what library you're using. My articles include instructions on how to blur an image, you could use that code with the areas you're detecting to blur an area.
3 Dec 2017 by completeknowitall
Um.. I thought I understood scan line... but when I step through the code, the source pointer remains empty and nothng gets transferred. I you have any advice, I'm listening. this is the core of my code, I'm hoping to do stuff to the pixels between reading and writing, but this part doesn't...
3 May 2011 by CPallini
Why don't you use CImage[^] instead?It can directly load jpeg and png files.
16 Dec 2013 by CPallini
GetBuffer is useless in both C++ and VB.NET programs.
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...
29 May 2015 by CPallini
We have an article on this very topic: "Extracting AVI Frames"[^].
29 May 2017 by CPallini
As already noted you usually can't gain much trying to compress a JPEG image, which is alreay compressed. In your code you changed the image size, making it smaller. If it is acceptable to make it even more smaller, then you may save some memory.
19 Dec 2012 by d rasool
hi.first of all sorry for my bad english.i need make a CBitmap or a streamdata from a System.Windows.Controls::Image(rendered out put)in a SDI mfc application (supporting \clr).here is my codes:using namespace System;using namespace System::IO;using namespace...
2 Apr 2013 by d_lucifer
hi friends, my application take snapshots using webcam and save them in a local folder. so i'm using following code to convert my Silverlight Image and send it through the Web Service. name of my web service is ImageService. ImageServiceSoapClient client = new...
21 Oct 2014 by DamithSL
Add: using Windows.UI.Xaml.Media.Imaging;Reference: Loading and processing bitmaps[^]
16 Apr 2014 by danee54
I am facing a problem: When i try to send a small size byte arraybyte[] s = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; it is easily received and inserted in the database successfully. But when i try to send a byte array of image, then it throws an exception as below:Quote:The request...
27 Jul 2011 by Darryl Bryk
Code is described for drawing an image as a 3D surface plot using OpenGL
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...
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...
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]);
22 Sep 2011 by DaveAuld
Here's an example;http://www.geekpedia.com/code140_Taking-Website-Screenshots-With-The-WebBrowser-Control.html[^]
8 Nov 2015 by dedo lore
Hi,i want to take continuously screenshots from five different positions on my desktop very fast. The CopyFromScreen mothod is unfortunately to slow.I found:Very fast screen capture using DirectX in C#[^]but i dont know:- how to take a screenshot with directX on my secondary...
2 Feb 2013 by defunktlemon
Hi. I would like to do some image processing in C# and need to align two images before applying a filter to them. I will attempt to do this by scanning the images at a fixed point in a small rectangular section, which I believe makes it necessary to use the Bitmap class. This section has a large...
2 Feb 2013 by defunktlemon
oh! I think I see. It worked. So, I just wasn't passing anything into the pictureBox. I am now passing the ofd file.Thanks a lot :)
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...
25 Jun 2014 by DrGrim
hello once again !could someone tell me how could i save an image that i drew (painted) on it with the same image quality as the original image ?i'm using this code to save the image :Using Bmp As New Bitmap(PictureBox4.Image, defaultWidth, defaultHeight) Using G As...
25 Jun 2014 by DrGrim
Thank you OriginalGriff , i have tried your way and with no result from what i have read on google this blur appears due to the bitmap resize .
4 Oct 2015 by dsz_848
I am trying to implement an application to get an image from the device and add it to the canvas then start drawing on it using brush and eraser (like snapchat idea) I used Drawing app as a basehttp://code.tutsplus.com/series/create-a-drawing-app-on-android--cms-704My problem for now is...
4 Nov 2012 by DX.Zong@hotmail.com
hi,I have written code like this: private static unsafe Point[] Hproject(Bitmap bmp) { int height = bmp.Height; int width = bmp.Width; Point[] result = new Point[height]; var data = bmp.LockBits(new Rectangle(0, 0, width, height),...
4 Nov 2012 by DX.Zong@hotmail.com
Is anyone help me to check the upper code?
17 Jul 2012 by E.F. Nijboer
The following should give you hex values:cout
29 Jun 2011 by Ed Gadziemski
An updated version of the WTL BmpView sample application using an OLE Picture object to handle multiple image types
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...
23 Jul 2012 by enhzflep
I did something like this years ago when creating a series of images that could be used as a height-map for surface of an animated, windswept ocean. Lots of fun at the time in that one... Complex Numbers --> rgb images. :wtf:Anyhow, a couple of questions that come to mind:1. What's the...
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...
16 Jan 2017 by EsakkiRaja
Hi all,I am trying to draw a line over the live video streaming in direct show application. Am successfully drawing a line but if I continuously want to create a line by calling the below function, i got an error E_OUTOFMEMORY from the SetAlphaBitmap(). Am calling drawlineOverlay() function...
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.
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...
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...
28 Sep 2011 by fasan21
I used normal deserializing in my webservice of my asp app.
28 Sep 2012 by fjdiewornncalwe
As Richard already noted, A PDF file is not a simple byte array. This[^] article may shed some light on how you need to pursue this.
16 Mar 2015 by Frankie-C
Read the four bytes together as DWORD, or unsigned int as you prefer, dimension your image arrays as same var type and you're done ;)#include #define WID 200#define DEP 600 typedef struct {int left;int top;int right;int bot;} rect; DWORD...
23 Nov 2011 by Freeboss
Hi,Let's create a:ObservableCollection BitmapsLists = new ObservableCollection();Then let's fill it with some random Images: foreach (string item in Directory.GetFiles("Some Folder")){ BitmapImage BitImage = new BitmapImage(); ...
23 Nov 2011 by Freeboss
I found it.. I'll post the solution l8---------------------------------Just Because you create a BitmapImage using a Uri as source doesn't mean that it it being created at the same time even if you set the BitmapCacheOption to whatever value..The BitmapImage is gonna get Loaded into...
18 Apr 2019 by Fueled By Decaff
You are trying to perform UI(User Interface) operations on a thread that is not the UI thread. Either create and display the Bitmap in the backgroundWorker1_ProgressChanged method or use this.Invoke to execute code on the Form UI thread and generate the Bitmap and display it in the method...