我想在图像上绘制一个单词时应用图像过滤器或蒙版.单词将具有透明效果以透视背景图像.是否有可能在本机IOS sdk或我需要不同的api来执行此操作.该图像由2个图像组成.一个是印度写的地方,另一个是印度信.
这是我用来从文本生成图像的代码.
-(UIImage *)imageFromText:(NSString *)text{
// set the font type and size
UIFont *font = [UIFont systemFontOfSize:100.0];
CGSize size = [text sizeWithFont:font];
// check if UIGraphicsBeginImageContextWithOptions is available (iOS is 4.0+)
if (UIGraphicsBeginImageContextWithOptions != NULL)
UIGraphicsBeginImageContextWithOptions(size,NO,0.0);
else
// iOS is < 4.0
UIGraphicsBeginImageContext(size);
// optional: add a shadow, to avoid clipping the shadow you should make the context size bigger
//
CGContextRef ctx = UIGraphicsGetCurrentContext();
CGContextSetShadowWithColor(ctx, CGSizeMake(0.0, 1.0), 5.0, [[UIColor blackColor] CGColor]);
CGContextSetBlendMode(ctx,kCGBlendModeNormal);
CGContextSetFillColorWithColor(ctx, [UIColor whiteColor].CGColor);
/*NSLog(@"Rect %@",CGContextGetClipBoundingBox(ctx));
CGImageRef …Run Code Online (Sandbox Code Playgroud) 我在java中做一个项目,它具有在数据库中添加文件的功能,我想使用winapi函数来选择文件.我该怎么做?
如果我们执行以下操作,则会收到错误:
class FGH{
public static Iterator reverse(List list) {
Collections.reverse(list);
return list.iterator();
}
public static void main(String[] args) {
List list = new ArrayList();
list.add("1"); list.add("2"); list.add("3");
/*for(Iterator it:reverse(list))
Iterator it=reverse(list);*/
for (Object obj: reverse(list))
System.out.print(obj + ", ");}}
Run Code Online (Sandbox Code Playgroud)
但是如果我们像这样修改代码我们就不会得到错误,那么它是否意味着我们不能迭代Iterator类型的对象?:
class FGH{
public static Iterator reverse(List list) {
Collections.reverse(list);
return list.iterator();
}
public static void main(String[] args) {
List list = new ArrayList();
list.add("1"); list.add("2"); list.add("3");
Iterator it=reverse(list);
while(it.hasNext()){
Object obj=it.next();
System.out.println(obj);
}
}}
Run Code Online (Sandbox Code Playgroud) 我们知道如果我们为列表声明泛型类型,我们可以在列表中添加字符串和整数.但代码似乎没有添加字符串.有什么问题我无法理解..
class GHJ{String s;GHJ(String s){this.s=s;}}
class DFR{
public static void main(String[] g){
List<? extends Object> list=new ArrayList();
list.add((new String("ffg")));// compiler error
list.add("df");// compiler error
list.add("sdd");// compiler error
list.add(new GHJ("dff"));// compiler error
String s= list.get(0);// compiler error
System.out.println(list+" "+s);
}
}
Run Code Online (Sandbox Code Playgroud)