Quantcast
Channel: beginners - openFrameworks
Viewing all articles
Browse latest Browse all 4929

Create a transparent PNG from textbuffer

$
0
0

@jaan wrote:

Hi.

I searched everywhere for a solution to convert text to image and save it to disk in transparent PNG format.

Currently I am creating an ofBuffer where I load the text file and draw it on screen using drawString. Then I have an ofImage object where I grab the screen (grabScreen) and then saving the image.


void ofApp::update(){
file.open(ofToDataPath("timing_data.txt"), ofFile::ReadWrite, false);
buffer = file.readToBuffer();
graafika.grabScreen(0,0,1024,768);
graafika.saveImage("test.png", OF_IMAGE_QUALITY_BEST);
}

void ofApp::draw(){
ofBackground(0,0,0,0);
ofEnableAlphaBlending();
ofSetColor(255,255,255);
verdana14.drawString(buffer.getText() ,10,10);
}

The perfect solution would be to save the buffer directly into a transparent image, without drawing it out on the window.

PS. using OF version 0084 in code blocks for windows

Thanks in advance!

Posts: 3

Participants: 3

Read full topic


Viewing all articles
Browse latest Browse all 4929

Trending Articles