How to preview a picture in .NET CF

F

Freesc

Hi all~

Are there some APIs like GetThumbnailImage or some relative methods
in .NET Compact Framework ,please?
Another question:
It's amazing that my WM device can give some thumbnailImages so
quickly. How can we access those thumbnailImages?

Thanks in advance

:)
 
M

Micha³ Sakowicz

Hi,

I don't know anything about native method for getting thumbnails, this
is what I'm using:

public System.Drawing.Bitmap GetThumbnail(System.Drawing.Bitmap
fullSizeImage)
{
int dstWidth = pbPreview.Width;
int dstHeight = pbPreview.Height;

decimal srcWidth = fullSizeImage.Width;
decimal srcHeight = fullSizeImage.Height;

decimal isoScalar = Math.Min((dstWidth / srcWidth), (dstHeight /
srcHeight));
decimal newWidth = isoScalar * srcWidth;
decimal newHeight = isoScalar * srcHeight;

return GetThumbnailImage(fullSizeImage, (int)newHeight,
(int)newWidth);
}

private static Bitmap GetThumbnailImage(Bitmap image, int width, int
height)
{
Bitmap bmp = new Bitmap(height, width);
Graphics gx = Graphics.FromImage(bmp);

// Resize the image
gx.DrawImage(image, new Rectangle(0, 0, height, width), new
Rectangle(0, 0, image.Width, image.Height), GraphicsUnit.Pixel);
gx.Dispose();

return bmp;
}

I'm using isotropic scaling it keeps the aspect ratio of a full image.

Michal
 
F

Freesc

Hi,

I don't know anything about native method for getting thumbnails, this
is what I'm using:

public System.Drawing.Bitmap GetThumbnail(System.Drawing.Bitmap
fullSizeImage)
{
        int dstWidth = pbPreview.Width;
        int dstHeight = pbPreview.Height;

        decimal srcWidth = fullSizeImage.Width;
        decimal srcHeight = fullSizeImage.Height;

        decimal isoScalar = Math.Min((dstWidth / srcWidth), (dstHeight /
srcHeight));
        decimal newWidth = isoScalar * srcWidth;
        decimal newHeight = isoScalar * srcHeight;

        return GetThumbnailImage(fullSizeImage, (int)newHeight,
(int)newWidth);

}

private static Bitmap GetThumbnailImage(Bitmap image, int width, int
height)
{
        Bitmap bmp = new Bitmap(height, width);
        Graphics gx = Graphics.FromImage(bmp);

        // Resize the image
        gx.DrawImage(image, new Rectangle(0, 0, height, width), new
Rectangle(0, 0, image.Width, image.Height), GraphicsUnit.Pixel);
        gx.Dispose();

        return bmp;

}

I'm using isotropic scaling it keeps the aspect ratio of a full image.

Michal






- Show quoted text -

thanks for your reply~ but i still don't know that where the
thumbnailImages which generated by system stored
 
F

Freesc

Hi,

I don't know anything about native method for getting thumbnails, this
is what I'm using:

public System.Drawing.Bitmap GetThumbnail(System.Drawing.Bitmap
fullSizeImage)
{
        int dstWidth = pbPreview.Width;
        int dstHeight = pbPreview.Height;

        decimal srcWidth = fullSizeImage.Width;
        decimal srcHeight = fullSizeImage.Height;

        decimal isoScalar = Math.Min((dstWidth / srcWidth), (dstHeight /
srcHeight));
        decimal newWidth = isoScalar * srcWidth;
        decimal newHeight = isoScalar * srcHeight;

        return GetThumbnailImage(fullSizeImage, (int)newHeight,
(int)newWidth);

}

private static Bitmap GetThumbnailImage(Bitmap image, int width, int
height)
{
        Bitmap bmp = new Bitmap(height, width);
        Graphics gx = Graphics.FromImage(bmp);

        // Resize the image
        gx.DrawImage(image, new Rectangle(0, 0, height, width), new
Rectangle(0, 0, image.Width, image.Height), GraphicsUnit.Pixel);
        gx.Dispose();

        return bmp;

}

I'm using isotropic scaling it keeps the aspect ratio of a full image.

Michal






- Show quoted text -

thanks for your reply~
i still don't know where the thumbnailImages which generated by
system are stored...

any suggestion?

:)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top