Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6240083
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T11:30:12+00:00 2026-05-24T11:30:12+00:00

How do I generate a simple BufferedImage and save it as a png-file in

  • 0

How do I generate a simple BufferedImage and save it as a png-file in Clojure?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T11:30:13+00:00Added an answer on May 24, 2026 at 11:30 am

    I’ve done something to this manner, briefly like this:

    (def bi (BufferedImage. 16 16 BufferedImage/TYPE_INT_ARGB))
    (def g (.createGraphics bi))
    ;; use g
    (.drawLine g 0 0 10 10)
    (.drawLine g 0 15 15 0)
    ;; save:
    (ImageIO/write bi "png"  (File. "test.png"))
    

    BufferedImage serves the Graphics2D context g and we use ImageIO to do the save.

    Example from a project of mine:

    (ns minemap.graphics
      (require minemap.core)
      (import java.io.File)
      (import java.awt.Color)
      (import java.awt.image.BufferedImage)
      (import javax.imageio.ImageIO))
    
    (defn draw-png
      "Take width, height, and the map of mines. Save to a file.
      Supposed to take a generate-random-map{,-perc} mapping."
      [width height minemap file]
      (let [block 5 ;block size
            bi (BufferedImage. (* block width) (* block height) BufferedImage/TYPE_INT_ARGB)
            g (.createGraphics bi)]
        (do
          (.setColor g (*colors* :background))
          (.fillRect g 0 0 (* block width) (* block height))
          (doseq [[[x y] high] minemap]
            (.setColor g (*colors* high))
            (.fillRect g (* block x) (* block y) block block))
          (ImageIO/write bi "png" (File. file)))))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to figure out how to generate a simple join that uses an
What am I doing wrong here: class Helo { // main: generate some simple
i would like to generate a very simple report with some images and text
As part of an attempt to generate a very simple looking sky, I've created
Simple enough question: I'm using python random module to generate random integers. I want
I wrote a simple Sinatra app that generate an image using rmagick from some
I haved generated simple CRUD application from seam-gen using seam generate-ui command, but the
I've written a simple Java applet to generate a technical image based upon some
I have written a simple Java class to generate the hash values of the
I am trying to Generate Fourier Spectrum of a simple image. But what I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.