crop

Able to capture UIImage as-is based on content mode from UIimageView?

别等时光非礼了梦想. 提交于 2019-12-02 10:20:04
I was wondering if there is a way to capture an UIImage as it appears as-is viewed in an UIImageView based on its contentMode . For example, if I pass a 3:4 aspect ratio to a square UIImageView , and use "Aspect Fit" as the contentMode , then I'd expect to see white letterboxes in the left and right parts the image to fill out the square. Would it then be possible to take whatever appears and save it directly as an new UIImage with the letter boxing? Thanks! You can capture a "screen shot" of the way a UIImageView is actually displayed by calling CALayer's renderInContext: method. https:/

Images not Cropped to correct size

别来无恙 提交于 2019-12-02 09:39:33
This jquery script can crop any image to correct size by tweaking the image url. This is the only Jquery script in web i have found for crop image of specific div/elements . Problem is suddenly the script is not able to crop image to correct size, the script's width-height variable is var w = 200 and var h = 150 but problem is width variable is not working, cropped images height and width became the same size. Means only height variable works, output cropped image became 150px X 150px . It should 200px X 150px. JS: var w = 200; var h = 150; $('.crop').find('img').each(function(n, image){ var

Cropping a cross rectangle from image using c#

喜夏-厌秋 提交于 2019-12-02 09:25:00
问题 What I want to do is basically cropping a rectangle from an image. However, it should satisfy some special cases: I want to crop an angled rectangle on image. I don't want to rotate the image and crop a rectangle :) If cropping exceeds the image size, I don't want to crop an empty background color. I want to crop from back of the starting point, that will end at starting point when rectangle size completed. I know I couldn't explain well so if I show what I want visually: The blue dot is the

Find the rectangle area of image to Crop

十年热恋 提交于 2019-12-02 08:02:53
I've image with the size of (352 x 240) And I want to crop the white area (the selected area as show below). I use this code to crop image , private static Image cropImage(Image img, Rectangle cropArea) { Bitmap bmpImage = new Bitmap(img); Bitmap bmpCrop = bmpImage.Clone(cropArea, bmpImage.PixelFormat); return (Image)(bmpCrop); } But I can't find the exact rectangle area for my need ! How can I find Rectangle value of selected area ? I just want to crop this area !! Thanks ! If you want to do it yourself you certainly can. But the details of how to do it best will depend a lot on exactly how

How to detect position of shape in image PHP [closed]

岁酱吖の 提交于 2019-12-02 07:30:19
I have image with white background and in that image i have some kind of shape - part of cloth. I need to find most left, up, right and bottom pixel. What is the most efficient way to do that? You can use the trimImage function to trim the image, and then look at the geometry and page info to find how the bounding box of the image that was left after trimming. $base = new Imagick(realpath('./trim.png')); $base->trimImage(0); $geometry = $base->getImageGeometry(); $pageInfo = $base->getImagePage(); printf ( "Width %d Height %d\n", $geometry['width'], $geometry['height'] ); printf( "OffsetX: %d

Flash image upload with mandatory crop?

梦想的初衷 提交于 2019-12-02 07:11:56
问题 Anyone know of a Flash file (image) uploader that will force a user to resize and/or crop their image BEFORE uploading it? To then upload it as well. Basically, I don't want my server processing the image resize/crop. I want to specify a target aspect ratio and have the user resize and crop their image to make it fit. I've seen cropping uploaders before but they all seem to be server side. I saw a Flex one but I'm not sure it's "mandatory" -- Basically if the user just uploads the image

Camera2 preview stretched when cropping with SCALER_CROP_REGION

橙三吉。 提交于 2019-12-02 06:04:54
问题 I want to display a preview in fullscreen using camera2 api. The camera size I selected is 4160x3120 (16:9) and my screen is 1080x1920 (9:16). Therefore if I want the preview to be right scaled I have to crop the camera output : Rect zoomCrop = new Rect(0, 0, 1755, 3120); captureRequestBuilder.set(CaptureRequest.SCALER_CROP_REGION, zoomCrop); The cropped preview should be of size 1755x3120 which has a ratio of 9:16 as well. Still the preview is streched. Question : Am I using SCALER_CROP

crop image to 4:3 aspect ratio c#

元气小坏坏 提交于 2019-12-02 05:28:18
I'm having a tough time wrapping my head around how to figure out the math for cropping any image that has a higher aspect ratio than 4:3 to 4:3. For example, I may have some images that are 16:9 that I I want resized and then cropped to 4:3. The resize bit I already have working, but it's maintaining the same aspect ratio. I know I need to use Graphics.DrawImage() But I'm not entirely sure what the parameters should be nor how I derive those parameters. Here's what I do know: var dimension = (double)bigSide/smallSide if(dimension > 1.4) { Graphics.DrawImage(resImage, new Rectangle(?, ?, ?, ?)

Crop image to smallest size by removing transparent pixels in java

别等时光非礼了梦想. 提交于 2019-12-02 05:12:37
I have a sprite sheet which has each image centered in a 32x32 cell. The actual images are not 32x32, but slightly smaller. What I'd like to do is take a cell and crop the transparent pixels so the image is as small as it can be. How would I do that in Java (JDK 6)? Here is an example of how I'm currently breaking up the tile sheet into cells: BufferedImage tilesheet = ImageIO.read(getClass().getResourceAsStream("/sheet.png"); for (int i = 0; i < 15; i++) { Image img = tilesheet.getSubimage(i * 32, 0, 32, 32); // crop here.. } My current idea was to test each pixel from the center working my

How to crop an FMX TBitmap

折月煮酒 提交于 2019-12-02 05:04:18
问题 I receive a bitmap via TCameraComponent.SampleBufferReady event. Then I need to crop the received image so that I get a, for instance, recangular image. I calculate the necessary parameters in the following method: procedure TPersonalF.SampleBufferReady(Sender: TObject; const ATime: TMediaTime); var BMP: TBitmap; X, Y, W, H: Word; begin Try BMP := TBitmap.Create; CameraComponent.SampleBufferToBitmap(BMP, true); if BMP.Width >= BMP.Height then //landscape begin W:=BMP.Height; H:=W; Y:=0; X: