Click here to Skip to main content
15,506,846 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i am receving the byte pointer from c++ it holds the address of the image,i need to get the thumbnail from the byte pointer address is it possible?

What I have tried:

what I tried is after getting the address i marshall to convert the byte pointer into byte array then i pass the byte array to get the thumbnail then i will get the thumbnail. now the problem is when i have large size file in byte array while marshaling it takes time

to reduce this time without marshalling the byte pointer i need to get the thumbnail

my code is

byte[] managedArray = new byte[img.nsize];//img.nsize //size of memory to be allocated
Marshal.Copy(img.pBitmap, managedArray, 0, (int)img.nsize); //img.pBitmap->byte pointer
byte[] Temp1 = MakeThumbnail(managedArray, 200, 200);



public static byte[] MakeThumbnail(byte[] myImage, int thumbWidth, int thumbHeight)
     {
         using (MemoryStream ms = new MemoryStream())
         using (Image thumbnail = Image.FromStream(new MemoryStream(myImage)).GetThumbnailImage(thumbWidth, thumbHeight, null, new IntPtr()))
         {
             thumbnail.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
             return ms.ToArray();
         }
     }
Posted
Comments
Gerry Schmitz 12-Jul-21 14:08pm    
The image either doesn't have a thumbnail; or the image you're handling is "too big" to make a sensible thumbnail; or it's not working at all. Start somewhere. (Anything near 300x300 is considered "big")
Fazil13 13-Jul-21 16:02pm    
Yes thanks now, I solved this i sent a whole image byte pointer instead of thumbnail pointer from dll and converted in to a thumbnail in my main application.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900