Well, I'm studying bitmaps, and I downloaded a pdf which said an image was an array of pixels. Since it is an array (which is quite logical) there is how to define points within the image, mark a region say so. The bitmap class as well should know how to read the properties of an image, such as the "size" of it, I wonder if there is any way to score points like 200x200 (example) and save that region into a new image.
The image of Braum, character of the game League of Legends, is random and this mark in black is to show what it would be this region which I mean.
image : https://i.stack.imgur.com/UFCoX.png
Related
hi i'm making photo mosaic creator but i can't replace a pixel with a set of pixel if any one know how to do this in c# please help cause i'm beginner in c#
and i understand the idea but i can't implement in c#
the idea is we have a input photo and we have a data set of small photos and we create an empty output photo and we put inside here the small photo from the data set after we take the pixel average RBG color from the input photo and we take the average RBG color of the small photo then we replace the pixel with the photo that have the same RGB color of the pixel and sort the small photo's in the output photo
Well, you don't "replace a pixel with an entire picture" when building a mosaic digitally. Instead, you create a brand new output image that is much larger than the input. Then you think about a grid on the output so that each input pixel corresponds to a grid square in the output. You then copy an image into each grid square, checking the corresponding input pixel to find out what image is appropriate.
I have not used it, but WriteableBitmapEx is a class for creating bitmaps and has a SetPixel method.
I'm currently working on a fractal generator in C# and I'm trying to export my set of coordinates to a very simple image file.
What i have is a 1-dimensional array of 3d point (x, y and z coordinate) and i wish to save it to an image where the z value will be the color of the pixel (grayscale only).
From what i gathered, the RAW format would be the easiest to work with, but even then i couldn't find documentation on it. I then looked at the namespace System.Drawing but i'm at a lost, it seems overly complicated for what i'm trying to achieve.
Is there an easy way to write such an image?
This link should help explain how to create an image pixel by pixel:
http://msdn.microsoft.com/en-us/library/system.drawing.image%28v=vs.80%29.aspx
then you should be able to use image1.Save with a string argument of the file location.
If you just want to display it on a winform, then you could keep the original source code from the link.
You can create a new image instead of loading one like so:
System.Drawing.Bitmap myMap = new System.Drawing.Bitmap(200,300); //200x300 pixels
I'm writing a CSS sprite sheet generator. I know there are several decent ones out there, but this is more a personal interest project than anything. I've got a decent algorithm now, but I'm ending up with a lot of leftover whitespace due to the way I'm calculating the position for the next image to pack. So my thought was this:
Given images A and B in C#, how could I find the top-left-most transparent area in image A that would accomodate the area of image B? In other words, assuming image B is a 10x10 image, how could I find the first 10x10 transparent area in image A (assuming there is one)?
I'm building a c# app to take photos of visitors for ID badges. I have found a c# wrapper for web cams so can take a snap shot easily, however I need to set the images to a certain number of pixels ideally with the persons head filling most of the area.
I imagine the best way to do this is to allow the end user to drag out a rectangle over the initial image with fixed x and y ratio covering the persons face. This would crop the image and do any resolution adjustment necessary.
Does anyone know of an example similar to this? I think I know how to do the rectangle and get my co-ordinates for the image cropping apart from fixing an x and y ratio. Obviously an example would be quicker than trying to write my own.
As of .Net 3.0, System.Windows.Media.Imaging provides a CroppedBitmap class that inherits from BitmapSource. Its constructor takes a BitmapSource and an Int32Rect. If you pass it your original image and your rect, it will return a cropped image as a BitmapSource.
So here are the details (I am using C# BTW):
I receive a 32bpp image (JPEG compressed) from a server. At some point, I would like to use the Palette property of a bitmap to color over-saturated pixels (brightness > 240) red. To do so, I need to get the image into an indexed format.
I have tried converting the image to a GIF, but I get quality loss. I have tried creating a new bitmap in an index format by these methods:
// causes a "Parameter not valid" error
Bitmap indexed = new Bitmap(orig.Width, orig.Height, PixelFormat.Indexed)
// no error, but the resulting image is black due to information loss I assume
Bitmap indexed = new Bitmap(orig.Width, orig.Height, PixelFormat.Format8bppIndexed)
I am at a loss now. The data in this image is changed constantly by the user, so I don't want to manually set pixels that have a brightness > 240 if I can avoid it. If I can set the palette once when the image is created, my work is done. If I am going about this the wrong way to begin with please let me know.
EDIT: Thanks guys, here is some more detail on what I am attempting to accomplish.
We are scanning a tissue slide at high resolution (pathology application). I write the interface to the actual scanner. We use a line-scan camera. To test the line rate of the camera, the user scans a very small portion and looks at the image.
The image is displayed next to a track bar. When the user moves the track bar (adjusting line rate), I change the overall intensity of the image in an attempt to model what it would look like at the new line rate. I do this using an ImageAttributes and ColorMatrix object currently.
When the user adjusts the track bar, I adjust the matrix. This does not give me per pixel information, but the performance is very nice. I could use LockBits and some unsafe code here, but I would rather not rewrite it if possible. When the new image is created, I would like for all pixels with a brightness value of > 240 to be colored red. I was thinking that defining a palette for the bitmap up front would be a clean way of doing this.
Going from 32bpp to 8bpp indexed will almost always result in quality loss, unless the original image has less than 256 colors total.
Can you create another image that is a overlay with the affected pixels red, then show both of those?
Since you are going for brightness > 240, you can convert the overlay to grayscale first, then to indexed to get the overbright pixels.
You don't specify what you are doing with it once you have tagged the offenders, so I don't know if that will work.
Sounds like something you could do easily with a pixel shader. Even very early shader models would support something as easy as this.
The question is however:
Can you include shader support in your application without too much hastle?
Do you know shader programming?
EDIT:
You probably don't have a 3D context where you can do stuff like this =/
I was mostly just airing my thoughts.
Manipulating the picture pixel by pixel should be doable in real-time with a single CPU shouldn't it?
If not, look into GPGPU programming and Open CL.
EDIT AGAIN:
If you gave some more details about what the app actually does we might help a bit more? For example, if you're making a web-app none of my tips would make sense.
Thanks for the help everyone. It seems that this can be solved using the ImageAttributes class and simply setting a color remap table.
ColorMap[] maps = new ColorMap[someNum]
// add mappings
imageAttrs.SetRemapTable(maps);
Thanks for the help again, at least I learned something.