Filling shapes using JAI
hi,
how can I fill a shape using JAI ? Is it a kind of convolution operation ?
I have binarized my image, and now I have a group of black pixels (we say, an hole) inside a face of white pixels.
thank you
My solution would be to work with the image in its raw format. Extract the image into a 2 dimensional array, loop throught the rows and columns and compare to your zero crossing window detector. after you have aquired the new image array, you set pixels that are next to an edge 0 and the rest #ffff. this will create a binary image (black and white) with the edges black and rest white. Be careful of your conventions used to determine what are edges. This may seem primitive, but thats just the way i think :P
-fastrike
Similar Messages
-
Turn a broad stroke into a filled shape?
Hi there,
I've made some lines/paths using a broad 20pt stroke which tapers to a point (using variable width profile).
is it possible to turn these paths into filled shapes so the paths would become the outer edges of the current stroke?
thanks for any help!
using CC
SteveYes, you can convert a stroke to a filled shape.
You can use either object>expand appearence then ungroup
or
You can use object>path>outline stroke -
Hello can any body help me to add color to my shape using jcombobox
please how can i fill color to my shape and change the line color of my shape using jcombobox here is my code
//package paint;
* PaintShapesDemo.java
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class PaintShapesDemo extends JFrame implements ActionListener
final private int RECT =1 ;
final private int CIRCLE = 2;
final private int POLY = 3 ;
final private int ELLI = 4 ;
final private int TRAN = 5 ;
private int shape;
JLabel Lcolor;
JLabel Fcolor;
JLabel headlebel,linecolorlabel,fillcolorlabel,labeldisplay;
JButton recbutton,cirbutton,polygonbutton,ellipsebutton;
JComboBox linecolor,fillcolor;
private ButtonGroup grShapes = new ButtonGroup();
private JPanel shapeSelectionPanel = new JPanel(new FlowLayout());
public PaintShapesDemo()
super("HAKIMADE");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBackground(Color.white);
setSize(800,600);
setLocationRelativeTo(null);
recbutton = new JButton("CIRCLE");
cirbutton = new JButton("ROUNDRECT");
polygonbutton = new JButton("ELLIPSE");
ellipsebutton = new JButton("RECTANGLE");
JPanel TP=new JPanel();
TP.setLayout(new FlowLayout(FlowLayout.CENTER));
TP.add(new JLabel("MY PAINT APPLICATION."));
JPanel panel1=new JPanel();
panel1.setLayout(new FlowLayout(FlowLayout.CENTER,10,40));
panel1.add(recbutton);
panel1.add(cirbutton);
panel1.add(polygonbutton);
panel1.add(ellipsebutton);
JPanel TP1=new JPanel();
TP1.setLayout(new BorderLayout());
TP1.add(TP,BorderLayout.NORTH);
TP1.add(panel1,BorderLayout.CENTER);
JPanel panel2=new JPanel();
panel2.setLayout(new FlowLayout(FlowLayout.CENTER,30,2));
Lcolor = new JLabel("SELECT LINE COLOR");
Fcolor = new JLabel("SELECT FILL COLOR");
panel2.add(Lcolor);
panel2.add(Fcolor);
JPanel panel3=new JPanel();
panel3.setLayout(new FlowLayout(FlowLayout.CENTER,30,2));
linecolor = new JComboBox();
linecolor.addItem("Choose the color");
linecolor.addItem("Gray");
linecolor.addItem("Orange");
linecolor.addItem("Magenta");
linecolor.addItem("Dark Gray");
fillcolor = new JComboBox();
fillcolor.addItem("Choose the color");
fillcolor.addItem("RED");
fillcolor.addItem("BLUE");
fillcolor.addItem("BLACK");
fillcolor.addItem("YELLOW");
panel3.add(linecolor);
panel3.add(fillcolor);
JPanel panel4=new JPanel();
panel4.setLayout(new BorderLayout());
panel4.add(panel2,BorderLayout.NORTH);
panel4.add(panel3,BorderLayout.CENTER);
shapeSelectionPanel.add(TP1);
shapeSelectionPanel.add(panel4);
shapeSelectionPanel.setBackground(Color.green);
shapeSelectionPanel.setBorder(BorderFactory.createLineBorder(Color.black));
shapeSelectionPanel.setPreferredSize(new Dimension(110, 100));
add(shapeSelectionPanel, BorderLayout.NORTH);
add(new DrawingPanel());
recbutton.addActionListener(this);
cirbutton.addActionListener(this);
polygonbutton.addActionListener(this);
ellipsebutton.addActionListener(this);
public static void main(final String args[])
new PaintShapesDemo().setVisible(true);
public void actionPerformed(final ActionEvent e)
shape = CIRCLE;
if(e.getSource() == cirbutton)
shape = RECT;
if(e.getSource() == recbutton)
shape = POLY;
if(e.getSource() == polygonbutton)
shape = ELLI;
if(e.getSource() == ellipsebutton)
shape = TRAN;
class DrawingPanel extends JPanel
private Image img;
private Graphics2D g2;
public DrawingPanel()
addMouseListener(new MouseAdapter(){public void mousePressed(MouseEvent e){drawShape(e.getX(), e.getY());}});
public void paintComponent(final Graphics g)
if(img == null)
img = createImage(getWidth(), getHeight());
g2 = (Graphics2D)img.getGraphics();
g.drawImage(img,0,0,null);
private void drawShape(final int x, final int y)
switch (shape)
case POLY: g2.drawOval(x,y,100,100);break;
case ELLI: g2.drawOval(x,y,100,50);break;
case RECT: g2.drawRoundRect(x,y,100, 70, 20, 20);break;
case CIRCLE: g2.drawRect(x,y,100,80);break;
case TRAN: g2.drawRect(x,y,100,80);
repaint();
}use CODE tags to post source code
read selected color from combobox and set colors Or declare two Strings lineColor and fillColor and set these variables on change of combo by adding ItemListener to the combo. and use that varables to set colors ..
Refer:
http://www.java2s.com/Code/Java/2D-Graphics-GUI/Arcdemonstrationscalemoverotatesheer.htm -
Hi,
I am drawing some shapes using java.awt.Shape, java.awt.geom.Area and java.awt.geom.GeneralPath and would like to know whether it's possible to fill these closed shapes with a color - or even better - with a pattern.
Thanks!er, yes, why not?
http://java.sun.com/docs/books/tutorial/2d/geometry/strokeandfill.html
-Puce -
Graphics2D fill(Shape) problem
When I use fill(shape), I try to draw fill graphics2D. The color of shape is there, but the center color of shape dispear after I finish drawing?
Who can tell me?
Thanks you very much!Based on the demo code you provided I would guess line 13 is the problem.
Here is an example demo program:
import java.awt.*;
import javax.swing.*;
public class FaceComponent
public static void main(String args[])
JPanel face = new JPanel()
protected void paintComponent(Graphics g)
super.paintComponent(g);
((Graphics2D)g).setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
g.drawArc( 100, 45, 80, 80, 0, 360);
g.setColor( Color.blue );
g.drawArc( 120, 70, 10, 10, 0, 360);
g.setColor( Color.blue );
g.drawArc( 150, 70, 10, 10, 0, 360);
g.setColor( Color.magenta );
g.drawLine ( 140, 85, 140, 100 );
g.setColor( Color.red );
g.drawArc ( 110, 55, 60, 60, 0, -180 );
face.setBackground(Color.WHITE);
face.setPreferredSize( new Dimension(250, 250) );
JScrollPane scrollPane = new JScrollPane( face );
scrollPane.setPreferredSize( new Dimension(300, 200) );
JFrame frame = new JFrame();
frame.getContentPane().add( scrollPane );
frame.pack();
frame.setLocationRelativeTo( null );
frame.setVisible( true );
}Hopefully your next posting will provide more information than the first posting. -
Created a circular shape using the elipse tool, how to change color?
This is a basic quesiton I know, but I'm lossed.
So I created a simple oval shape using the elipse tool, and the color is black. How can I change the color?What setting did you use in the Options Bar: Shape Layers, Paths, Fill Pixels?
In the first case it would be easiest to change the color, simply double-click the resultant Solid Color Layer’s icon in the Layers Panel and select a new color in the Color Picker. -
Problem while loading a JApplet ( which uses JAI ) on Netscape across ssl
Hi Folks...
I m having some problem in applet.. can any1 of u guys help me???? My problem is as follows..
I m having 2 JApplets (Swing applet) one of the applet is using JAI (Java Advance Imaging APIs). I m trying 2 load both the applets in IE as well as in Netscape across SSL (ie thru https protocol) .Both the applet can be loaded on IE across SSL. but when i m trying to load the applet on Netscape, one of the applet which is using JAI is not getting loaded across SSL. The other applet which is not using JAI is running fine across SSL on Netscape also.
I m getting some exception.. Is this exception comming bcoz JAI is not compatible with Netscape r bcoz of somethinf else??? If it is bcoz of the fact that Netscape does'nt have any support for JAI across SSL. then watz the possible solution 4 that. How can i overcome by this problem. Its very urgent.. i need to do it any how... Plz plz help me out if u guys have any idea abt this.. any help is most welcome..
My ids r
[email protected]
[email protected]
tks...
JameelExactly what exception are you getting? That will really help in determining the problem. Also, do you have the same problems when going over a regular connection (i.e. not over SSL)?
Kate -
Problem Printing Images Using JAI
I'm using JAI in an application that prints images. My program works fine on my development machine (Windows XP), but when I put it on my Windows Server 2008 r2-64 bit, it crashes for certain images (these are large images of land plats) that go to a particular printer (OCE PlotWave 300) It prints my smaller images that are printing on a variety of printers just fine (images of Mortgages etc..) and it prints everything just fine on my development machine. What could possibly be causing this?
Edited by: LongStranjeTrip on Feb 2, 2011 4:34 PM
Edited by: LongStranjeTrip on Feb 4, 2011 8:11 AMI'm using JAI in an application that prints images. My program works fine on my development machine (Windows XP), but when I put it on my Windows Server 2008 r2-64 bit, it crashes for certain images (these are large images of land plats) that go to a particular printer (OCE PlotWave 300) It prints my smaller images that are printing on a variety of printers just fine (images of Mortgages etc..) and it prints everything just fine on my development machine. What could possibly be causing this?
Edited by: LongStranjeTrip on Feb 2, 2011 4:34 PM
Edited by: LongStranjeTrip on Feb 4, 2011 8:11 AM -
How to resize image in JSP using JAI ??!!
Please help me how to resize an JPEG image from my JSP, could I use JAI lib ? how ?
Hello,
I had the same problem few months ago ( in that case i used Jimi instead of JAI).
The answer to your question is: use the java class called "Image".
Infact you can use JAI just for load or save to disk your image that you have to resize and then use the following code to resize the image :
Image imgResized = img.getScaledInstance(100,1,Image.SCALE_AREA_AVERAGING);
The object "img" is the image to resize and the object "imgResized" is the image resized with width equals to 100 and with a right height.
I used Jimi just to save my image and i think that with JAI there is a method to do this.
You can use JAI to load in memory your image too so you can avoid problem with MediaTraker class.
I hope that this can help you.
Cheers.
Stefano -
Downgrading Image Resolution Using JAI
I am interested in downgrading the resolution of TIFF images that I am inserting into a PDF to reduce the document's file size. The TIFF images are either CCITT G4 bitonal or JPEG RGB. What would be the best approach to doing this using JAI?
I appreciate any suggestions.
Youssef Eldakar
Bibliotheca AlexandrinaYoussef
The following code will load a TIFF image (or JPEG or some other formats that I can't remember) into a PlanarImage object and then rescale it according to the scale factors and then save as a TIFF.
For example if you wanted to change a 320 x 240 image to a 160 x 120 use xScaleFactor and yScaleFactor of 0.5.
public static PlanarImage rescale(String inputFilename, String outputFilename, float xScaleFactor, float yScaleFactor)
// load the image from the file
PlanarImage image = JAI.create("fileload", inputFilename);
ParameterBlock rescaleParameters = new ParameterBlock();
rescaleParameters.addSource(image);
rescaleParameters.add(xScaleFactor);
rescaleParameters.add(yScaleFactor);
// saving as TIFF is a little more complicated than loading
try
FileOutputStream out = new FileOutputStream(outputFilename);
TIFFEncodeParam parameters = new TIFFEncodeParam();
ImageEncoder encoder = ImageCodec.createImageEncoder("TIFF", out, parameters);
try
encoder.encode(image);
out.close();
catch (IOException e)
System.out.println("Failed to encode the image");
catch (java.io.FileNotFoundException ioEx)
System.out.println("Could not write to file " + filename); -
Drawing Rectangle shape using Labview 8.0
Is it possible to draw a rectagle shape using Labview 8.0? I found in the HELP content tat it did exist some function related, but when i click on "place to block diagram" it doesnt work. So i susect tat it is for further version of Labview.
I have an idea of how to draw the rectagle, which is by drawing line from point to point. Since i need to draw multiple of rectangle, so i hope tat there is an easier way to do it.
Thanks for ur time and help.You can have the numbers created, programmatically
Attachments:
Example_VI_BD2.png 3 KB -
Hi there,
this might be a very simple question, but couldn't figure it out ..
I made a Title in Premiere and I want to draw a shape with the pen tool.
However this only results into a shape with line instead of it being filled.
So my question: how to draw a filled shape in Premiere Pro with the pen tool?
Thanks in advanceSet Graphic Type to Filled Bezier, that will fill the shape.
-
Scan and fill form using Acrobat 6.0
How can I scan hardcopy of a form, save as PDF, open the form in Acrobat 6.0, and fill in the blanks (fields)?
Thanks Dave.
I'm aware that my 6.0 acrobat is way out of date. But I thought I created a fillable form a few years ago using it. But in that case it probably was a PDF going into the process, not a scanned form. Also, I was using vista at the time and now have win 7/64bit.
I'll try the OCR routine but your post suggests what I suspected, that I can't get to where I'm going from here.
Date: Tue, 25 Mar 2014 19:27:21 -0700
From: [email protected]
To: [email protected]
Subject: Scan and fill form using Acrobat 6.0
Re: Scan and fill form using Acrobat 6.0
created by CtDave in Creating, Editing & Exporting PDFs - View the full discussion
As Acrobat 6 went out of support / obsolete many years ago you'll want to be sure the OS is compatible and the scanner software is compatible.
Use Acrobat's create PDF from scanner feature (review the Help file if needed, the Help PDF was installed when Acrobat 6 was installed).
So, you'll now have that PDF.
But, it is not yet a form PDF.
The scanner output is an image so you have an image / a picture as the PDF page content.
You may want to use Acrobat's OCR feature to provide a hidden layer of renderable characters.
Use Acrobat's form tools to build your form. As Acrobat 6 is long ago gone by I don't recall if it had a "form wizard". Check the Help PDF.
Be well...
Please note that the Adobe Forums do not accept email attachments. If you want to embed a screen image in your message please visit the thread in the forum to embed the image at http://forums.adobe.com/message/6242371#6242371
Replies to this message go to everyone subscribed to this thread, not directly to the person who posted the message. To post a reply, either reply to this email or visit the message page: http://forums.adobe.com/message/6242371#6242371
To unsubscribe from this thread, please visit the message page at http://forums.adobe.com/message/6242371#6242371. In the Actions box on the right, click the Stop Email Notifications link.
Start a new discussion in Creating, Editing & Exporting PDFs at Adobe Community
For more information about maintaining your forum email notifications please go to http://forums.adobe.com/thread/416458?tstart=0. -
Filling shapes and changing line weights will not show until export.
When I draw a character, i cannot change line weight of fill shapes. When I do so it remains unchanged, however once I export everything is fine and okay.
This image below is how it looks. Even though it is colored.
Once I export I get this
Can someone please help me?menu/view/outline
or pres command+y -
Using parallax scrolling on a browser fill shape?
Hi everyone,
Is it possible to apply parallax scrolling onto a shape that is extended to horizontally fill up the browser? I'm creating a single page scroll website and a want a shape to cover up a certain fraction of the bottom of the browser (I can't use pin because then the shape will move with the bottom of the browser depending on the size of the window.) Parallax works fine on the shape until I extend it to the browser borders and then parallax grays out. Will this be supported in a future update? Is there another way for me to achieve this effect? Thanks!
JackieFrom Muse Release Notes - http://helpx.adobe.com/muse/release-note/adobe-muse-release-notes.html.
Note Scroll Motion Effects are not available for 100% browser width objects, pinned objects, items that are inline within text, items within a group or items within a widget.
You would also find a similar note in the information tooltip for Scroll Motion under the Effects panel in the Control strip. Please feel free to submit it as a feature request in our Ideas section.
Thanks,
Vinayak
Maybe you are looking for
-
I have 4 children under the age of 11. I would love it if there was an app that said you have to do a certain amount of minutes on educational apps first THEN you could do fun games. At the very least have a running total at the end of each day and w
-
I want to transfer e-mails from MS outlook to CRM,I have created folder u201CSAP CRM E-Mail Transferu201D using Personalize setting under groupware integration, emails form folder u201CCRM E-Mail Transferu201D only need to transfer to CRM Inbox. But
-
Hi All, i am going to create File2File scenario using File content conversion(Flat file). Please let me know how to set the content conversion parameters. Any body have the documentation for this, please send me ASAP. Thanks & Regards, Nagarjuna.
-
IDOC segment handling with OOP
Let's say we have the following simplified ORDERS05 IDOC ORDERS05 Purchasing/Sales Header E1EDK01 IDoc: Document header general data E1EDK14 IDoc: Document Header Organizational Data Rows ( Items ) E1EDP01 IDoc: Document Item General Data And would l
-
Photos on ipad organized/dated. When synched with computer they became jumbled /dated missing. Now labeled "10impt". How is it corrected?