Reputation: 1148
I have a problem that I need to have a jpeg image with dpi 500 first it come from base64 I could converted it directly to jpeg but I don't know how to set the dpi to system.drawing.image
I have a solution is to get the image as bitmap then use the setresolution function to reset it to 500*500 and that what I need but to reconvert the bitmap again to jpeg it needs to be saved on physical drive and also I couldn't do that
so I just need to get from image or bitmap to jpeg with 500*500 resloution actually I also will read it again to array of bytes but I need this array from a jpeg image with 500*500 dpi and the converted image from base64 is not 500*500 dpi
any idea will be appreciated
Upvotes: 0
Views: 493
Reputation: 54725
Seems you have some misunderstanding what dpi means. 500 means that each inch of an object in an image is represented using 500 pixels. So, dpi isn't really a characteristic of an abstract image. It's a characteristic of how a real object is represented with an image. That means you don't need to change image's resolution at all.
Upvotes: 1
Reputation: 700680
The Image
class is abstract, so you can't have an instance of that class. What you have is really an instance of the Bitmap
class, but a reference to that with the type Image
.
So, you just have to cast the reference to the actual class of the object, and you can access its methods:
((Bitmap)theImage).SetResolution(500, 500);
Upvotes: 1