-
Jun 22nd, 2024, 12:42 PM
#1
Thread Starter
Addicted Member
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-Twip widthheightproblem.zip
-
Jun 22nd, 2024, 01:06 PM
#2
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.
-
Jun 22nd, 2024, 08:32 PM
#3
Thread Starter
Addicted Member
Re: crop image height and width not resize 3-pixel
Thanks baka i try API BitBlt but i failed.
-
Jun 23rd, 2024, 01:52 AM
#4
Thread Starter
Addicted Member
Re: crop image height and width not resize 3-pixel
-
Jun 23rd, 2024, 02:25 AM
#5
Re: crop image height and width not resize 3-pixel
Start with explaining what failed and maybe showing some code
-
Jun 23rd, 2024, 04:01 AM
#6
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.
-
Jun 23rd, 2024, 06:26 AM
#7
Thread Starter
Addicted Member
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
-
Jun 23rd, 2024, 08:40 AM
#8
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).
-
Jun 23rd, 2024, 08:41 AM
#9
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).
-
Jun 23rd, 2024, 08:43 AM
#10
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).
-
Jun 23rd, 2024, 12:20 PM
#11
Thread Starter
Addicted Member
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.
-
Jun 23rd, 2024, 12:58 PM
#12
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
-
Jun 23rd, 2024, 01:09 PM
#13
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).
-
Jun 23rd, 2024, 01:31 PM
#14
Junior Member
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.
-
Jun 23rd, 2024, 02:09 PM
#15
Thread Starter
Addicted Member
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.

widthheightproblem.zip
-
Jun 23rd, 2024, 02:10 PM
#16
Thread Starter
Addicted Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|