Android special crop library - java

I need to crop images for a "Photoprint" app of mine. To create appropriate image for printing paper, image will be scaled up, scaled down and cropped by dragging to specific field of image in a frame. Only short edge or long edge of the image could have empty space, two edges shouldn't have empty spaces at the same time. Any of height or width should fit the crop frame. By the way, crop frame should stay the same size. For example; for a 5x7" printing paper, frame will have 504x306px size.
Could you help me, image crop algorithm?

Related

Java Canvas scale to window

I want my canvas to have a fixed width and high so when say item 200px, by 100px that is relative to the canvas but may get display bigger or smaller depending on the user screen size. So what it want to know is can make canvas 640x360 or what ever size i want but display it the bigger i can on the users screen as zoom so all distastes are the same.

Java Graphics2D. Drawing scaled image on a retina display

I'm creating a 64x64 pixels VolitileImage, drawing some images and shapes on it (using drawImage, fillRect etc.), then I want to draw this image stretched up to 640x640 pixels. I expect to see the 64x64 matrix of 10x10 screen pixels squares. That's what I see on non-retina display. But when I try this on a retina-display I actually see 128x128 matrix of 5x5 squares.
Here's what I'm talking about:
Is there a way of "turning off" this behavior? Because what I need is to display 64x64 image stretched 10 times.
UPD:
Adding an compileable example: https://gist.github.com/miriti/651cb4b768cc5a076341
Each balack and white point is 1 pixel in a 64x64 image. Notice the difference between regular display and retina:

How to create a larger frame in Java

I am drawing a coordinate system with weight, height =10000*10000 on a frame. It too big, my graph can't fully display. I try to draw on scroll but it's lag. I want to display my graph on a frame 10000*10000, fit with my screen computer to print screen. What should I do?
You have to scale you graph. You know, Earth is very big but it fits map that can be shown on a screen of your smart phone :)
This means that if for example you want to show rectangle of 10000*10000 on screen that has (for example) 1000 pixels you have to scale your picture 10 times.
Option 1: Set the size of the JFrame on which you are displaying the graph to the desired size.
setSize(WIDTH, HEIGHT);
where WIDTH and HEIGHT are in pixels.
OR
Option 2: Scale the drawing. That is, simply divide each dimension in the drawing by 2 to make it half the size.

Create a Dicom image

I am currently working with a DICOM project in java. I am calculating the dicom values such as depth, off-axis ratio, width and height. I want to create a sample image with the calculated width and height. I should be a gray scale image, with varying densities of gray color in appropriate area. I have created a sample image with imagemagick, using concentric circles. Bit am not getting the exact image. It does not look like an actual dicom image. The variation of gray color does not have a linear behavior. Sample image is attached. Please suggest any other method to create dicom image. The density values are available in a list. depending upon the distance from the center, the gray color also changes according to the density value provided.
Pixel Data or image in DICOM data set is always rectangular and image is described using Rows (0028, 0010) and Columns (0028, 0011) attributes. So the best way to implement this is to draw your circular image on a rectangular background. Fill the background with a color that is not present in your image. Use the Pixel Padding Value (0028,0120) to specify the color used to pad grayscale images (those with a Photometric Interpretation of MONOCHROME1 or MONOCHROME2) to rectangular format.
If you do not have any color to spare (with-in the bit stored), you can add Overlay Plane or Display Shutter to the data set to mask the area that is not part of image.

Automatically crop image boundaries

I'm looking for an automatic way to grab a piece of a bitmap and extract a certain part of it.
Let me explain:
If I have this image:
http://imgur.com/B9U9E
It has a big white border. (see link for better white result) I'm looking for a way to only grab the dialog above. So no white borders around the dialog. Is there a way to do this by code or with a library?
You should know that the image could have any form and positioned anywhere on the white dialog.
So a user draws something on the white panel and i need the program to automatically make a rectangle about where the users drew on the canvas and save that bitmap where the user drew on the canvas (Everything in between that rectangle).
Pseudocode
Define the background color.
Scan from the left, right, bottom, top and store the locations of the transitions from background to drawing.
The rectangle defined by (left, bottom) and (right, top) defines the cropping area
For a Java code example, please see: How to auto crop an image white border in Java?
Look into Bitmap.createBitmap.

Categories