How draw TEXT to Image
I have a Image component loaded from file :
private Image bgImage;
bgImage = new ImageIcon("images/BackGround.jpg").getImage();
And I want draw text to this image.
How to do it?
Best Regards.
Related to this posting:
http://forum.java.sun.com/thread.jspa?threadID=756975
It would be nice if the OP will keep all the information together in one place so everybody knows what has already been suggested.
Similar Messages
-
Can someone help me with drawing text and a custom image in cocoa?
I am trying to learn how to draw, and when I look at the tutorial, instead of getting straight to the point on how to draw text at a coordinate, it talks about the concepts of how to draw. I get that, but exactly what methods and what objects should I use?
For instance, the java code:
+public void drawComponent(Graphics g){+
+Graphics2D g2 = (Graphics2D) g;+
+g2.drawString("Hello, World!", 10, 20);+
draws the good old "Hello, World!" on a line starting 20 pixels down and 10 pixels across. How would I do the same in objective-c in a customized view? Based on the tutorial, I need specify the code in the
+- (void)drawRect: (NSRect) rect+
method.
Also, how would I draw a picture(.gif and .png format)?Here's a very basic example:
- (void)drawRect:(NSRect)rect {
// draw text
NSString *myString = @"Hello World";
NSFont *font = [NSFont boldSystemFontOfSize:24];
NSColor *color = [NSColor blueColor];
NSDictionary *attrs = [NSDictionary dictionaryWithObjectsAndKeys:
font, NSFontAttributeName,
color, NSForegroundColorAttributeName,
nil];
[myString drawAtPoint:NSMakePoint(20, 0) withAttributes:attrs];
// draw image
NSImage *myImage = [NSImage imageNamed:@"picture1.png"];
[myImage drawAtPoint:NSMakePoint(20, 40)
fromRect:NSZeroRect operation:NSCompositeCopy fraction:1.0];
Since the above uses the imageNamed convenience method of NSImage, the arg must be the name of an image file you've previously added to the main bundle (Project->Add to Project). The code for a gif would be exactly the same.
For more details see [Drawing Images into a View|https://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/Coc oaDrawingGuide/Images/Images.html#//apple_ref/doc/uid/TP40003290-CH208-BCIIBDAD] and [Simple Text Drawing|https://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/ CocoaDrawingGuide/Text/Text.html#//apple_ref/doc/uid/TP40003290-CH209-SW1] in the +Cocoa Drawing Guide+. Btw, the above is for OS X, since you asked about Cocoa. iPhone code is now called Cocoa Touch, so I hope I guessed the platform right. In case you really wanted iPhone, the code would be quite similar, but you'll need to substitute CGPointMake for NSMakePoint, UIColor for NSColor, UIImage for NSImage, and use a method like [drawAtPoint:forWidth:withFont:minFontSize:actualFontSize:lineBreakMode:baselin eAdjustment:|http://developer.apple.com/iphone/library/documentation/UIKit/Refer ence/NSStringUIKit_Additions/Reference/Reference.html#//appleref/doc/uid/TP40006893-CH3-SW14] for your text. You'll also only need one arg for the [drawAtPoint|http://developer.apple.com/iphone/library/documentation/UIKit/Refe rence/UIImageClass/Reference/Reference.html#//appleref/doc/uid/TP40006890-CH3-SW24] method of UIImage.
Hope that helps get you started!
- Ray -
How to draw text vertically, or in an angle
please help me how to draw text vertically, or in an angle
I robbed the framework from Dr Las or 74phillip (don't remember which) ...
import java.awt.*;
import java.awt.geom.*;
import javax.swing.*;
import javax.swing.event.*;
public class AngleText extends JPanel {
private int degrees = 16;
private JSpinner degreesSpinner;
public AngleText () {
setBackground ( Color.WHITE );
} // AngleText constructor
protected void paintComponent ( Graphics _g ) {
super.paintComponent ( _g );
Graphics2D g = (Graphics2D)_g;
g.setRenderingHint ( RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON );
AffineTransform at = AffineTransform.getRotateInstance ( Math.toRadians ( degrees ) );
Font f = g.getFont();
g.setFont ( f.deriveFont ( at ) );
g.drawString ( "Rotating Text!", getWidth()/2, getHeight()/2 );
g.setRenderingHint ( RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF );
} // paintComponent
public JPanel getUIPanel () {
SpinnerModel degreesModel = new SpinnerNumberModel (
degrees // initial
,0 // min
,360 // max
,2 // step
degreesSpinner = new JSpinner ( degreesModel );
degreesSpinner.addChangeListener ( new DegreesTracker() );
JPanel panel = new JPanel();
panel.add ( degreesSpinner );
return panel;
} // getUIPanel
// DegreesTracker
private class DegreesTracker implements ChangeListener {
public void stateChanged ( ChangeEvent e ) {
Integer i = (Integer)((JSpinner)e.getSource()).getValue();
degrees = i.intValue ();
repaint();
} // DegreesTracker
// main
public static void main ( String[] args ) {
JFrame f = new JFrame ( "AngleText" );
f.setDefaultCloseOperation ( JFrame.EXIT_ON_CLOSE );
AngleText app = new AngleText();
f.getContentPane().add ( app );
f.getContentPane().add ( app.getUIPanel(), BorderLayout.SOUTH );
f.setSize ( 200, 200 );
f.setVisible ( true );
} // main
} // AngleText -
How do you find images in LR 2.4 that have been imported from CS4 Bridge and have been assigned a color label in Bridge? I have set both LR 2.4 and my CS4 Bridge to match the text for each color to be the same (eg. Green for green, etc), and the filter search in LR 2.4 shows that a label has been assigned, but I am unable to identify and locate the specific images in LR 2.4 that have had a color label assigned from CS4 Bridge. I have tried to search via attribute, metadata, text, etc...Is it necessary to re-assign color labels all over again, image by image, in LR 2.4, or is there a way to automatically have the color labels assigned in CS4 Bridge be assigned and searchable to the images after they have been imported into the LR 2.4 catalogue from the Bridge program?
JohnM.
I closed both programs and re-imported photos and re-tried the action of having LR read the XMP metadata from the CS4 files, and it seems to work now just fine...don't know why now and not before, but thanks much. Is there a way to have LR do this automatically upon import of images from CS4? I tried to do this with an import metadata preset, but no luck. It seems as if I can only do this once the images have already been imported into LR, and then to have to have LR read the metadata from the CS4 Bridge files. thanks gain. -
How can i copy line with text and image to ms word
When I insert an image in textflow using InlineGraphicElement it works, but when I copy the line with the image to MS Word it copies only the text (not the image).
How can i copy the image to MS Word?If you want copy formatted text and image to MS Word, you need to give MS Word rtf markup, because Word can recognize rtf markup but not TLF markup.
So you need to create a custom clipboard to paste a rtf markup. It's a large feature for you, because you need a tlf-rtf converter in your custom clipboard.
TLF Custom Clipboard Example:
package
import flash.display.Sprite;
import flash.desktop.ClipboardFormats;
import flashx.textLayout.container.ContainerController;
import flashx.textLayout.conversion.ITextImporter;
import flashx.textLayout.conversion.TextConverter;
import flashx.textLayout.edit.EditManager;
import flashx.textLayout.elements.*;
import flashx.undo.UndoManager;
// Example code to install a custom clipboard format. This one installs at the front of the list (overriding all later formats)
// and adds a handler for plain text that strips out all consonants (everything except aeiou).
public class CustomClipboardFormat extends Sprite
public function CustomClipboardFormat()
var textFlow:TextFlow = setup();
TextConverter.addFormatAt(0, "vowelsOnly_extraList", VowelsOnlyImporter, AdditionalListExporter, "air:text" /* it's a converter for cliboard */);
private const markup:String = '<TextFlow whiteSpaceCollapse="preserve" version="2.0.0" xmlns="http://ns.adobe.com/textLayout/2008"><p><span color=\"0x00ff00\">Anything you paste will have all consonants removed.</span></p></TextFlow>';
private function setup():TextFlow
var importer:ITextImporter = TextConverter.getImporter(TextConverter.TEXT_LAYOUT_FORMAT);
var textFlow:TextFlow = importer.importToFlow(markup);
textFlow.flowComposer.addController(new ContainerController(this,500,200));
textFlow.interactionManager = new EditManager(new UndoManager());
textFlow.flowComposer.updateAllControllers();
return textFlow;
import flashx.textLayout.conversion.ITextExporter;
import flashx.textLayout.conversion.ConverterBase;
import flashx.textLayout.conversion.ITextImporter;
import flashx.textLayout.conversion.TextConverter;
import flashx.textLayout.elements.IConfiguration;
import flashx.textLayout.elements.TextFlow;
class VowelsOnlyImporter extends ConverterBase implements ITextImporter
protected var _config:IConfiguration = null;
/** Constructor */
public function VowelsOnlyImporter()
super();
public function importToFlow(source:Object):TextFlow
if (source is String)
var firstChar:String = (source as String).charAt(0);
firstChar = firstChar.toLowerCase();
// This filter only applies if the first character is a vowel
if (firstChar == 'a' || firstChar == 'i' || firstChar == 'e' || firstChar == 'o' || firstChar == 'u')
var pattern:RegExp = /([b-df-hj-np-tv-z])*/g;
source = source.replace(pattern, "");
var importer:ITextImporter = TextConverter.getImporter(TextConverter.PLAIN_TEXT_FORMAT);
importer.useClipboardAnnotations = this.useClipboardAnnotations;
importer.configuration = _config;
return importer.importToFlow(source);
return null;
public function get configuration():IConfiguration
return _config;
public function set configuration(value:IConfiguration):void
_config = value;
import flashx.textLayout.elements.ParagraphElement;
import flashx.textLayout.elements.SpanElement;
import flashx.textLayout.elements.ListElement;
import flashx.textLayout.elements.ListItemElement;
class AdditionalListExporter extends ConverterBase implements ITextExporter
/** Constructor */
public function AdditionalListExporter()
super();
public function export(source:TextFlow, conversionType:String):Object
if (source is TextFlow)
source.getChildAt(source.numChildren - 1).setStyle(MERGE_TO_NEXT_ON_PASTE, false);
var list:ListElement = new ListElement();
var item1:ListItemElement = new ListItemElement();
var item2:ListItemElement = new ListItemElement();
var para1:ParagraphElement = new ParagraphElement();
var para2:ParagraphElement = new ParagraphElement();
var span1:SpanElement = new SpanElement();
span1.text = "ab";
var span2:SpanElement = new SpanElement();
span2.text = "cd";
list.addChild(item1);
list.addChild(item2);
item1.addChild(para1);
para1.addChild(span1);
item2.addChild(para2);
para2.addChild(span2);
source.addChild(list);
var exporter:ITextExporter = TextConverter.getExporter(TextConverter.TEXT_LAYOUT_FORMAT);
exporter.useClipboardAnnotations = this.useClipboardAnnotations;
return exporter.export(source, conversionType);
return null; -
How can i create a simple netweaver portal page that shows text and images?
Hi,
i have a simple question or maybe it's not so simple.
I am completly new to SAP Netweaver 2004s Portal. At the moment i'm trying to understand the struture of the whole thing. I already know how to create roles, worksets and pages and i know how to combine the different elements so a user can acces them.
And now i want to create a simple portal page that shows text and images. Is it possible to create such a simple page with the portal content studio? What iView do i have to use?
(I just want to create a start page with a welcome text on it.)Marc
Considering that you would any ways go ahead with complex development from this simple start page I recommend create a Web dynpro Iview for your start page (include the Iview in your page).
For putting the contents use Netweaver Developer studio to build a simple start page application and put your static text on that Iview.
Please go through the following log after your NWDS development is over - This will make you comfortable for further challenging work.
http://help.sap.com/saphelp_erp2005/helpdata/en/b7/ca934257a5c96ae10000000a155106/frameset.htm
Do reward points if this helps and let me know of you want anything more. -
how do you add text to images in Aperture?
the user can superimpose text (inc. metadata) anywhere: on the image, in the border, over both.
Learn something new every single day...
Regards
TD -
How to make mouseover effect text show image in popup window or tooltip?
I am trying to display a popup image in a new window when the mouse moves over some text. Or perhaps, the image could display in a tooltip when the mouse moves over some text.
However, I have achieved the functionality of an image appearing above the text when the mouse moves over some text. This is how I did this:
I put this code into the Page HTML Header:
<script type="text/javascript">
<!--
function setFirstChildImgDisplay(el,vis) {
if(!el || !el.getElementsByTagName) return;
el.getElementsByTagName('img')[0].style.display=vis;
// -->
</script>
I created a region and put this in the Region's Title field:
{div onmouseover="setFirstChildImgDisplay(this,'inline')" onmouseout="setFirstChildImgDisplay(this,'none')">Check out Page 1 here <img src="#WORKSPACE_IMAGES#DGNR Preview Page 1.bmp" alt="Page 1 Preview" style="display:none;">{/div}
I am thinking that I should not have all of this code in the Region's Title field. But, I don't know where else to put it in APEX.
So my questions are:
1. how to get an image to display in a popup window or as a tooltip when the mouse is moved over some text?
2. where should the {div} content be placed in APEX, if not in the Title field?
Please note that I used '{' & '}' instead of '<' & '>' just so the div would display in this post.
Also, I would like to give credit to this website because this is where I found out how to do what I have provided above.
http://forums.devshed.com/web-design-help-2/mouseover-effect-text-shows-image-321876.html
Thank you in advance,
MaggieIt's just an image map. Play with the settings. Here's a shape layer making a hole in the water and adding a bit of color.
-
How to invoke alt-text for images in a PDF file by Automation
Hi,
Can any one help me?
How to invoke Alt-text for Images in a PDF file using script?
Thanks for looking into this.
Regards,
SudhakarWhat do you mean "invoke" alt-text? If Alt-text is there, then it will be presented to a screen reader.
-
Facebook is not loading properly and all my text and images are lined up along the right side of the page. How can this get fixed to the way it use to look?
Everyone who logs into Facebook on my Firefox has this problem however if we use Internet Explorer - facebook looks normal.If you have increased the minimum font size then try the default setting "none" as a high value can cause issues like you described.
* Tools > Options > Content : Fonts & Colors > Advanced > Minimum Font Size (none)
*Tools > Options > Content : Fonts & Colors > Advanced > [X] "Allow pages to choose their own fonts, instead of my selections above" -
Hello everybody,
I searched over the net and in this support section for a solution to my problem, but i didnt find any, so...here I am asking you experts.
Through a particular use of different actions I make a logo "compose" in the first slide of my presentation (the logo is composed by text and images that interact), then in the second slide i make it resize so it goes 50% of its size and moves down like a TV logo, in the corner of the slide, and I want it to stay there for all the lenght of the presentation.
It might be a stupid problem, but I didnt understand how to keep it there, 50% of its size and always in that position. If i duplicate the slide I obviously duplicate the 100%-size-logo, not its 50%-size-version, and if i shrink it in order to make it be 50% of its size the text size doesnt shrink so i have to change the text size manually, but the visual effect is imperfect.
Lets summarize:
slide 1: text appears, image appears, the text and the image move and "compose" the logo
slide 2: the complete logo reduces its size to 50% and moves in the lower corner of the presentation, in the place I want it to be for, lets say, 20 slides
slide 3: i want to have this logo already reduced in size and in its position, in the right lower corner, but if i try to group the different parts of the composed logo and i try to squeeze them the font doesnt change its size, I only squeeze the area that the text occupies.
Some help please guys?
Thanks in advance,
Dom-
(add: the problem is kind of similar to this: https://discussions.apple.com/message/9179367#9179367 . the idea of making a slide that contains the logo and text in the exact positions they would be after the move and scale actions is good and that was my first attempt, the probem is that it looks impossible to me to create a second "little" version of the logo that looks exactly the same of the first one that i reduced, so i hope there is some way to tell the app to use "the first logo, only resized the way i want", and thats the point where the problem with the size of the text comes out)Hi pritam,
The “maintain proportions of window for different monitor
resolutions” property will maintain the proportional size of the front panel
(its x and y sizes) when opened in a different resolution. The front panel
objects will not be resized and will appear larger (and may not fit inside the
front panel) when saved in a higher resolution, and moved to a lower
resolution. You can use the “Keep window proportions” property to achieve the
same results.
To have both the front panel dimensions and front panel
controls scale, you need to have both the above property and the “scale all
objects on front panel as the window resizes” selected. The labels will not be
resized by this.
I tried using both properties on two monitors and noticed
that the change does not occur when the resolutions between the monitors are
different. I had to lower both monitors’ resolution to see the change work
properly.
Please post back if you have any questions. Have a great day!
Ryan D.
District Sales Manager for Boston & Northern New England
National Instruments -
I upgraded to mavericks and I cannot make text or images bigger with the trackpad. It only zooms in the document. How to change that?
Hi Rohit,
If you have questions about the Accessibility features of Mavericks, you may find the following article helpful:
OS X Mavericks: Use accessibility features
http://support.apple.com/kb/PH14322
Regards,
- Brenden -
When I print a webpage from FF how can I make the text and images bigger?
I am trying to print an eticket for a flight. The text on the schedule comes out too small and the UPC symbol's black lines look ganged together. I know I can view it zoomed up, but how do I make the text and images stay zoomed so they will print out that way?
I upgraded but the problem remains. At least with Firefox I do have the option to print a selection even if it mangles the top and bottom lines. With Safari or Chrome I have no option to print a selection. At the moment the only way to get a complete copy of the selection is to copy to openoffice etc and print from there.
-
How to convert a image layer to a text layer any idea? a image looks like a text in layers box
How to convert a image layer to a text layer any idea? a image looks like a text in layers box
You can't convert an image into a text layer. What you can do is clip an image to a text layer so that just the image layer shows up where there is text. Create a text layer, then above it put your image layer. Hold down the alt/opt key and click between the two layers to clip them.
-
How to create an image contains text
hello folks,
I want create a zoomable gaphical application that contains text. By a simple example, I will put the paragraph of text in a rectangle. I used BufferedImage and Graphics2D for draw the rectangle and using function drawString(String, X, Y) for draw Text but I have met a wrap problem when the rectangle is zoomed. I want that when the rectangle is zooming there is not the difference of wrapping of two rectangles. (there is only the change of zoom ratio of 2 rectangles)
Pls, give me a solution.
many thanks,
jav
PS: Sorry for my bad english. :-)met a wrap problemIf you want to clarify your problem for audience of the forum, you shoul post a small demo code that is generally compilable, runnable and could reproduce your problem. See: http://homepage1.nifty.com/algafield/sscce.html and this wiki.
As a stabbing in the dark, I'd say the problem could be solved by constantly recreating/redrawing the text-image during the zoom operation. Optimization might be preloading of the images.
Maybe you are looking for
-
How to do message mapping in IDoc or RFC to file transfer ?
Hello guys. I have a doubt. I know how to do an IDoc to file or RFC to file scenario. But how to do mapping in an Idoc to file or RFC to file scenario ? As I understand mapping is done in the sender. But IDoc or RFhas no interface as its used for SAP
-
Java System Clipboard error implementing inhereted lostOwnership procedure
I am trying to get a string from the system clipboard manipulate it then put the manipulated string back on the system clipboard. I'm fairly certain i have the accessing the clipboard correct, but i can't figure out an error i'm getting with part of
-
Hi all, I am using two report scripts in ASO cube, 1. to export Budget data 2. to export actual data The amount of data in the cube is same for these two scenarios and all the other dimensions are also fixed at the same state in the two report script
-
CS6 deployment error with Application Manager Enterprise 3.1 Edition
Hello everyone, I am currently trying to create a DesignWebPremium and Master Collection CS6 deployment package with AMEE 3.1 (Application Manager Enterprise Edition) on Windows 7 EE x64 without any luck. I keep getting the following error log: 11/16
-
I have an older itouch with 2.2.1 software where can I find apps?
I have an older itouch with 2.2.1 software, where can I find apps for it?