flatten

How to create an image from UILabel?

断了今生、忘了曾经 提交于 2019-11-27 07:38:01
I'm currently developing a simple photoshop like application on iphone. When I want to flatten my layers, the labels are at the good position but with a bad font size. Here's my code to flatten : UIGraphicsBeginImageContext(CGSizeMake(widthDocument,widthDocument)); for (UILabel *label in arrayLabel) { [label drawTextInRect:label.frame]; } UIImage *image = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); Anybody can help me ? DJPlayer From: pulling an UIImage from a UITextView or UILabel gives white image . // iOS - (UIImage *)grabImage { // Create a "canvas" (image

How to copy certain files (w/o folder hierarchy), but do not overwrite existing files?

淺唱寂寞╮ 提交于 2019-11-27 05:34:11
问题 I need to copy all *.doc files (but not folders whose names match *.doc ) from a network folder \\server\source (including files in all nested folders) to a local folder C:\destination without preserving the nested folders hierarchy (i.e. all files should go directly into C:\destination and no nested folders should be created in C:\destination ). In case there are several files with the same name from different subfolders of \\server\source , only the first one should be copied and never

How to flatten a tuple in python

僤鯓⒐⒋嵵緔 提交于 2019-11-27 05:24:35
I have the following element of a list, and the list is 100 elements long. [(50, (2.7387451803816479e-13, 219))] How do I convert each element to look like this? [(50, 2.7387451803816479e-13, 219)] user2357112 [(a, b, c) for a, (b, c) in l] Tuple packing and unpacking solves the problem. New in Python 3.5 with the additional tuple unpacking introduced in PEP 448 , you can use starred expressions in tuple literals such that you can use >>> l = [(50, (2.7387451803816479e-13, 219)), (40, (3.4587451803816479e-13, 220))] >>> [(a, *rest) for a, rest in l] [(50, 2.738745180381648e-13, 219), (40, 3

XML shredding via XSLT in Java

折月煮酒 提交于 2019-11-27 05:22:16
I need to transform large XML files that have a nested (hierarchical) structure of the form <Root> Flat XML Hierarchical XML (multiple blocks, some repetitive) Flat XML </Root> into a flatter ("shredded") form, with 1 block for each repetitive nested block. The data has numerous different tags and hierarchy variations (especially in the number of tags of the shredded XML before and after the hierarchical XML), so ideally no assumption should be made about tag and attribute names, or the hierarchical level. A top-level view of the hierarchy for just 4 levels would look something like <Level 1>

Convert 2 dimensional array

▼魔方 西西 提交于 2019-11-27 04:48:55
What is selectMany.ToArray() method? Is it a built in method in C# ? I need to convert two dimensional array to one dimensional array. Marc Gravell If you mean a jagged array ( T[][] ), SelectMany is your friend. If, however, you mean a rectangular array ( T[,] ), then you can just enumerate the date data via foreach - or: int[,] from = new int[,] {{1,2},{3,4},{5,6}}; int[] to = from.Cast<int>().ToArray(); SelectMany is a projection operator, an extension method provided by the namespace System.Linq. It performs a one to many element projection over a sequence, allowing you to "flatten" the

JavaScript flattening an array of arrays of objects

非 Y 不嫁゛ 提交于 2019-11-27 04:30:44
I have an array which contains several arrays, each containing several objects, similar to this. [[object1, object2],[object1],[object1,object2,object3]] Here is a screenhot of the object logged to the console. What would be the best approach to flattening this out so it just an array of objects? I've tried this with no luck: console.log(searchData); var m = [].concat.apply([],searchData); console.log(m); searchData logs out the screenshot above, but m logs out [ ] Here is the actual contents of searchData: [[{"_id":"55064111d06b96d974937a6f","title":"Generic Title","shortname":"generic-title"

Flatten FDF / XFDF forms to PDF in PHP with utf-8 characters

寵の児 提交于 2019-11-27 03:56:10
问题 My scenario: A PDF template with formfields: template.pdf An XFDF file that contains the data to be filled in: fieldData.xfdf Now I need to have these to files combined & flattened. pdftk does the job easily within php: exec("pdftk template.pdf fill_form fieldData.xfdf output flatFile.pdf flatten"); Unfortunately this does not work with full utf-8 support. For example: Cyrillic and greek letters get scrambled. I used Arial for this, with an unicode character set. How can I accomplish to

Python 3: Flattening nested dictionaries and lists within dictionaries

℡╲_俬逩灬. 提交于 2019-11-27 03:40:14
问题 I am dealing with a complex nested dictionary and list data structure. I need to flatten the data and bring all nested items to level 0. See below example for more clarity : {a:1,b:2,c:{c1:[{c11:1,c12:2,c13:3},{c21:1,c22:2,c23:3}],d1:[{d11:1,d12:2,d13:3},{d21:1,d22:2,d23:3}]},x:1,y:2} i need to flatten this to: {a:1,b:2,c_c1_c11:1, c_c1_c12:2,c_c1_c13:3,c_c1_c21:1,c_c1_c22:2,c_c1_c23:3, c_d1,d11:1...and so on} I took reference from the first answer in this post, but it can only work if i have

How to flatten a List of Futures in Scala

放肆的年华 提交于 2019-11-27 01:35:04
问题 I want to take this val: val f = List(Future(1), Future(2), Future(3)) Perform some operation on it (I was thinking flatten) f.flatten And get this result scala> f.flatten = List(1,2,3) If the flatten method isn't appropriate here, that's fine. As long as I get to the result. Thanks! 回答1: Future.sequence takes a List[Future[T]] and returns a Future[List[T]] . You can do Future.sequence(f) and then use map or onComplete on it to access the list of values. 来源: https://stackoverflow.com

How to “flatten” or “index” 3D-array in 1D array?

…衆ロ難τιáo~ 提交于 2019-11-26 21:47:29
I am trying to flatten 3D array into 1D array for "chunk" system in my game. It's a 3D-block game and basically I want the chunk system to be almost identical to Minecraft's system (however, this isn't Minecraft clone by any measure). In my previous 2D-games I have accessed the flattened array with following algorithm: Tiles[x + y * WIDTH] However, this obviously doesn't work with 3D since it's missing the Z-axis. I have no idea how to implement this sort of algorithm in 3D-space. Width, height and depth are all constants (and width is just as large as height). Is it just x + y*WIDTH + Z*DEPTH