Results 1 to 16 of 16

Thread: crop image height and width not resize 3-pixel

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Sep 2013
    Posts
    191

    crop image height and width not resize 3-pixel

    Hello brother,
    i read all post and search google and also try many code but i failed.
    i thing my problem is very simple but i failed.
    i crop an image in picture1 and draw picture2 who height and width are same.

    Detail:

    i draw two picture box who name picture1 and picture2 also Picture1.ScaleMode = 3-pixel , Picture2.ScaleMode = 3-pixel
    draw 4 textbox

    when i crop image who selected area crop image is good but not size equal.

    i send pic and code

    i used
    Picture1.ScaleMode = 3-pixel , Picture2.ScaleMode = 3-pixel

    i not using
    Picture1.ScaleMode = 1-Twip , Picture2.ScaleMode = 1-TwipName:  1.jpg
Views: 145
Size:  22.7 KBwidthheightproblem.zip

  2. #2
    The Idiot
    Join Date
    Dec 2014
    Posts
    2,901

    Re: crop image height and width not resize 3-pixel

    use the API BitBlt, its fast and easy to use and its in pixel by default.

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Sep 2013
    Posts
    191

    Re: crop image height and width not resize 3-pixel

    Thanks baka i try API BitBlt but i failed.

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Sep 2013
    Posts
    191

    Re: crop image height and width not resize 3-pixel

    no body any solution?

  5. #5
    PowerPoster Arnoutdv's Avatar
    Join Date
    Oct 2013
    Posts
    6,418

    Re: crop image height and width not resize 3-pixel

    Start with explaining what failed and maybe showing some code

  6. #6
    The Idiot
    Join Date
    Dec 2014
    Posts
    2,901

    Re: crop image height and width not resize 3-pixel

    yeah, u need to show code of that "crop"- function. surely u are doing something wrong,
    like not considering the autoredraw, wrong hDC or even wrong values.

  7. #7

    Thread Starter
    Addicted Member
    Join Date
    Sep 2013
    Posts
    191

    Re: crop image height and width not resize 3-pixel

    Picture2.AutoSize = True
    m_X1 = Text1.Text
    m_Y1 = Text2.Text
    wid = Text3.Text
    hgt = Text4.Text
    BitBlt Picture2.hDC, 0, 0, ScaleX(wid, vbPixels), ScaleX(hgt, vbPixels), Picture1.hDC, m_X1, m_Y1, vbSrcCopy
    SavePicture Picture2.Picture, App.Path & "\number.bmp"

    and other code

    BitBlt Picture2.hDC, 0, 0, ScaleX(wid, vbPixels), ScaleX(hgt, vbPixels), Picture1.hDC, m_X1, m_Y1, vbSrcCopy
    Picture2.Picture = Picture2.Image
    SavePicture Picture2.Picture, App.Path & "\number.bmp"

    and other code

    Picture2.AutoSize = True

    m_X1 = Text1.Text
    m_Y1 = Text2.Text
    wid = Text3.Text
    hgt = Text4.Text

    Picture2.Width = wid + (Picture2.Width - Picture2.ScaleWidth)
    Picture2.Height = hgt + (Picture2.Height - Picture2.ScaleHeight)

    BitBlt Picture2.hDC, 0, 0, ScaleX(wid, vbPixels), ScaleX(hgt, vbPixels), Picture1.hDC, m_X1, m_Y1, vbSrcCopy

  8. #8
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    9,535

    Re: crop image height and width not resize 3-pixel

    1-do you not mean Picture2.Image = Picture1.Image???
    Sam I am (as well as Confused at times).

  9. #9
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    9,535

    Re: crop image height and width not resize 3-pixel

    2-In your OP, you DID have Picture2.Scalemode set to Twips.
    Sam I am (as well as Confused at times).

  10. #10
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    9,535

    Re: crop image height and width not resize 3-pixel

    3-What are you trying to do? CROP a PORTION of Picture1 and loading it into Picture2?
    Sam I am (as well as Confused at times).

  11. #11

    Thread Starter
    Addicted Member
    Join Date
    Sep 2013
    Posts
    191

    Re: crop image height and width not resize 3-pixel

    My question is so difficult that no solution is coming out.
    I repeat.
    I took two picture boxes.
    The scale mode of both is 3-Pixcel.
    I want to cut some part from the first image and bring it to the second image.
    Cut according to the dimension I wrote in the text boxs.
    And this cut part has to be saved in ( d ) drive .

    8 is its top and 5 is left
    Its width is 218 and its length is 50
    On ScaleMode 3-pixcel.
    Second image width and height not working.

  12. #12
    The Idiot
    Join Date
    Dec 2014
    Posts
    2,901

    Re: crop image height and width not resize 3-pixel

    if u study BitBlt u will understand:

    - all values "are" pixel, no need to do any scaling
    - .AutoRedraw need to be off when u use it

    do not do any savepicture/Picture2.Picture = Picture2.Image

  13. #13
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    9,535

    Re: crop image height and width not resize 3-pixel

    Here's an example in Post # 6 of something very similar to what you are trying to accomplish....maybe it will help.

    https://www.vbforums.com/showthread....pped-rectangle
    Sam I am (as well as Confused at times).

  14. #14
    Junior Member
    Join Date
    Dec 2008
    Posts
    20

    Re: crop image height and width not resize 3-pixel

    put the following in your button click event

    dim N as long
    N = 3
    Picture2.AutoRedraw=True
    Picture2.PaintPicture Picture1.Picture, 0, 0, Picture1.ScaleWidth - 0, Picture1.ScaleHeight - 0, N , N , Picture2.ScaleWidth - 2 * N , Picture2.ScaleHeight - 2 * N


    ( note : i assume the op is not much concerned with speed of operation )
    ( note : the following is one line
    Picture2.PaintPicture Picture1.Picture, 0, 0, Picture1.ScaleWidth - 0, Picture1.ScaleHeight - 0, N , N , Picture2.ScaleWidth - 2 * N , Picture2.ScaleHeight - 2 * N
    )
    Last edited by ntstatic; Jun 23rd, 2024 at 01:37 PM.

  15. #15

    Thread Starter
    Addicted Member
    Join Date
    Sep 2013
    Posts
    191

    Re: crop image height and width not resize 3-pixel

    SamOscarBrown ,ntstatic and baka thanks

    but this code not good i upload picture and project different dimension.
    i crop the image with dimension .
    different image different dimension.


    Name:  dinmation.bmp
Views: 76
Size:  181.2 KB
    widthheightproblem.zip

  16. #16

    Thread Starter
    Addicted Member
    Join Date
    Sep 2013
    Posts
    191

    Re: crop image height and width not resize 3-pixel

    this dimension is all 3-pixcel.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width