when uploading adhar image file, it will be save but when fetching then masling adhar image file will be displayed in grid view.
Loading
when uploading adhar image file, it will be save but when fetching then masling adhar image file will be displayed in grid view.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend4days leftRegister
Tahir AnsariRank #366 · 6.8K reputationPosted Oct 20, 2023, 10:36 AM EDT
we load the original image, create a black rectangle to cover the last 4 digits, and then save the modified image.
Display Masked Image In your grid view, display the masked image that you generated in step 2. You can simply bind the path to the masked image file to the grid view, and it will display the modified image.
// Load the original image using (Image originalImage = Image.FromFile("path_to_original_image.jpg")) using (Bitmap bitmap = new Bitmap(originalImage)) using (Graphics graphics = Graphics.FromImage(bitmap)) { // Define the region to be masked (the last 4 digits) int x = 100; // Adjust these coordinates based on your image int y = 100; // Adjust these coordinates based on your image int width = 200; // Adjust the width based on your image int height = 50; // Adjust the height based on your image // Create a black rectangle to cover the region using (Brush brush = new SolidBrush(Color.Black)) { graphics.FillRectangle(brush, x, y, width, height); } // Save the masked image bitmap.Save("path_to_masked_image.jpg", ImageFormat.Jpeg); }Ashutosh SinghRank #549 · 4.4K reputationPosted Oct 25, 2023, 9:18 AM EDT
Masking Aadhar Card: To mask the last 4 digits of the Aadhar card, you can use an image processing library like ImageMagick or a programming language with image manipulation capabilities, such as C# in a .NET Core application. Below is an example using C#:
using System.Drawing; using System.Drawing.Imaging; public byte[] MaskAadharCard(byte[] originalImageData) { using (MemoryStream ms = new MemoryStream(originalImageData)) { using (Image image = Image.FromStream(ms)) using (Bitmap bitmap = new Bitmap(image)) { int width = bitmap.Width; int height = bitmap.Height; int startX = width - 100; // Adjust based on your image size for (int x = startX; x < width; x++) { for (int y = 0; y < height; y++) { bitmap.SetPixel(x, y, Color.Black); } } using (MemoryStream maskedStream = new MemoryStream()) { bitmap.Save(maskedStream, ImageFormat.Jpeg); // Or other suitable format return maskedStream.ToArray(); } } } }Display in GridView: When displaying the images in your GridView, retrieve the masked image and show it in the GridView.