Episode #125 of the Stack Overflow podcast is here. We talk Tilde Club and mechanical keyboards. Listen now

New answers tagged

5

Reversing the condition of if (originalImage != null) and returning early will remove one level of indentation. The less indentation some code shows the easier to read it will become. catch to just rethrow, althought you did it in the correct way, doesn't buy you anything. Just remove the try..catch..finally and enclose the usage of graphics with an usage ...


2

The secret to performance is to choose the appropriate data structures which lay out the memory as raw arrays of bytes (or uint8_t values). This is done by creating cython typed memoryviews from numpy arrays or images loaded through PIL. This applies to the border list as well; that is, I create an array of (x, y) coordinates rather than a list of python ...


0

kotlinify getViewModel I would change protected fun <T: ViewModel>getViewModel(c: Class<T>): T = ViewModelProviders.of(activity)[c] } //with protected fun <T: ViewModel>getViewModel(c: KClass<T>): T = ViewModelProviders.of(activity)[c.java] } after replacing the Class with KClass in the activity, you can ...


6

var zipFile = ZipFile.OpenRead(ChapterLocation); ... zipFile.Dispose(); One word: using. using (var stream = z.Open()) { using (var mstream = new MemoryStream()) { stream.CopyTo(mstream); mstream.Position = 0; var bitmap = new BitmapImage(); bitmap.BeginInit(); ...


Top 50 recent answers are included