Splitting jpg image

abc abc 351 Reputation points
2021-02-05T04:58:21.84+00:00

Hi,

I need to split the jpg image into 4 images. Instead of splitting the image into 4 after creating single image, my requirement is I need to create 4 images by splitting bitmap bit data or hbitmap.

Is it possible to split bitmap bit data or hbitmap to create 4 images?
Is there any other way using win32 apis

Thanks

Windows development Windows API - Win32
Developer technologies C++
0 comments No comments
{count} votes

Accepted answer
  1. Castorix31 90,521 Reputation points
    2021-02-05T09:03:40.967+00:00

    From HBITMAP, you can just use StretchBlt to divide it in 4 parts :
    64349-stretchblt.jpg


2 additional answers

Sort by: Most helpful
  1. Strive Sun-MSFT 426 Reputation points
    2021-02-05T06:56:09.087+00:00

    Hello, @abc abc

    For jpg image, consider using WIC to get its handle.

    Here is a sample,

    How to Load a Bitmap from a File

    After getting the handle of the picture, draw it to hdc, and use the BitBlt function for bit block transmission of color data. Just set the coordinates and size of the picture.

    ----------

    Thank you!

    If the answer is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

  2. Viorel 122.5K Reputation points
    2021-02-05T08:08:28.123+00:00

    If you already have the full image (HBITMAP), you can create a Bitmap object using Image::FromHbitmap, then you can extract a rectangle using Bitmap::Clone.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.