0
A
回答
1
做一個BufferedImage,並調用setPixel。
的BufferedImage:http://download.oracle.com/javase/1.4.2/docs/api/java/awt/image/BufferedImage.html
如果你想BMP文件,那麼你可以使用ImageIO.write(BufferedImage的, 「BMP」,新的文件( 「mybmp.bmp」));
我會給你鏈接到ImageIO類,但堆棧溢出阻止我發垃圾郵件。
-1
在科特林:
// As it happens default color model has AARRGGBB format
// in other words alpha + RBG
val colorModel = ColorModel.getRGBdefault()
val raster = colorModel.createCompatibleWritableRaster(
horizontalRes, verticalRes)
val bufferedImage = BufferedImage(
colorModel, raster, colorModel.isAlphaPremultiplied, null)
// rawArgbData = array of int's.
// every int has format = 0xFF|R|G|B (MSB is alpha)
raster.setDataElements(
0, 0, horizontalRes, verticalRes,
rawArgbData)
// finally save
ImageIO.write(bufferedImage, "PNG", File(filePath))
有可能與ARGB格式保存位圖的問題,看到這一點:ImageIO.write bmp does not work
相關問題
- 1. class in class in java
- 2. 24bit int in php
- 3. always int int = float float in python
- 4. Int32 to Int in Haskell
- 5. float vs int in cuda
- 6. Select language in Hypertable in Java
- 7. Intptr,Intptr.Zero和ref int in java等價物:
- 8. Mergesort in java
- 9. 「object = this」in java
- 10. Toggle Key in Java
- 11. AddressBook in Java
- 12. this.set(charHere)in JAVA
- 13. IN JAVA PROGRAMMING
- 14. NSNumber VS Int,Float in Swift Dictionary
- 15. 在MySQL(VARCHAR)與IN(INT)
- 16. String to int cast in php
- 17. int in raw_input不起作用
- 18. power int number while in loop
- 19. Prod in shapeless的Int值
- 20. C#List implementation ... in Java
- 21. Collections.sort()in Java
- 22. PreparedStatement Insert in Java
- 23. NETWORKDAYS.INTL in Java
- 24. PrintWriter&File in java
- 25. Persistant in Java
- 26. xmltask in java 1.7?
- 27. Shapiro Wilks in java
- 28. LINQ's Single in java?
- 29. HighScore in java?
- 30. Memcached in java
OP搜索一個** ** Java的解決方案。雖然** Kotlin **確實轉換爲* JVM *兼容* Bytecode *其源代碼當然與* Java編譯器不兼容*這種OP可能只能使用這個想法,而不是代碼本身。 – Zabuza 2017-07-22 12:12:30
@Zabuza在提供的示例中,Java和Kotlin之間的差異很小,只需將'val'更改爲完整類型名稱並在這裏和那裏添加'new',就可以編譯java解決方案。無論如何,我爲*自己*添加了這個答案,因爲這是第一個彈出的問題,當我將其保存爲「保存int數組到bmp」時。我添加了我的代碼,它與OP問題無關,但可能爲某人節省幾個小時的研究時間...... – csharpfolk 2017-07-22 13:11:38