Dear all,
how does one create a simple graph in BMP or PNG format?
GDI+?
Can a metafile.emf simply be converted?
I need to output some performance characteristics graphically.
Thanks,
]an
-
- Active Member
- Posts: 36
- Joined: 4 Mar 2000 0:01
Well basically creating a graph is easy. You create a picture (vpi::pictOpen), make the wanted draw operations (axis, axis numbers, header, observations etc) and finally save the picture using vip::pictSave. The picture is saved in BMP format.
Saving the picture directly in PNG (or JPEG etc) format could be done like this
GDI+ is a real jungle and if your needs are simply to draw a simple chart I would recommend you forget GDI+. During the past years I have occasionally worked with the GDI+ "problem". I have had no big difficulties in producing rather complex GDI+ charts or drawings on the screen, but when it comes to saving the GDI+ picture I have not managed to find out how it is done. I have tried to figure out it several times and then got frustrated in the lack of success and have "forgotten" GDI+ for the next 6 months. 
Saving the picture directly in PNG (or JPEG etc) format could be done like this
Code: Select all
savePictureToFile(Picture,FileName) :-
vpi::pictSave(Picture,"x.bmp"),
gdiplus_api::startup(),
Image = gdiPlus::loadImageFromFile("x.bmp"),
TYPE = imageType(fileName::getExtension(FileName)),
CLSID = gdiPlus_api::gdipTryGetImageEncoder(TYPE),
gdiplus_api::checkStatus(gdiPlus_native::gdipSaveImageToFile(Image,FileName,CLSID,null),"gdipSaveImageToFile"),
gdiPlus_api::gdipDisposeImage(Image),
gdiplus_api::shutdown(),
!.

-
- VIP Member
- Posts: 83
- Joined: 6 Mar 2000 0:01
Thanks Kari,
I'll try to explore the possibilities along the lines you suggest.
The VIP picturedraw example provides the opposite from what I need. The example assumes BMP and JPG files on disk and displays them on the screen.
OpenGL and the likes seem to be a bit heavy for my purpose, to use an understatement.
]an
I'll try to explore the possibilities along the lines you suggest.
The VIP picturedraw example provides the opposite from what I need. The example assumes BMP and JPG files on disk and displays them on the screen.
OpenGL and the likes seem to be a bit heavy for my purpose, to use an understatement.
]an
-
- VIP Member
- Posts: 108
- Joined: 6 Mar 2000 0:01
Jan,
the vpi picture predicates are relatively easy to use from scratch.
here is a short example code that I have used to create a terabytes worth of sample images for my NN research.
P.
the vpi picture predicates are relatively easy to use from scratch.
here is a short example code that I have used to create a terabytes worth of sample images for my NN research.
Code: Select all
class facts - text_to_encode
picWin : pictureCanvas := erroneous.
controlRCT : rct := rct(0,0,256,256).
...
clauses
drawGraphicMorse(INint):-
...
controlRCT = rct(_X1,_Y1,X2,Y2),
picWin := pictureCanvas::new(256,256),
% commented out due to te 9,944 'limit'
% picWin : setFont(vpi::fontCreateByName("Courier New",titleFontSize)),
% sets black on white
Fore = color_black,
Back = color_white,
% sets the inverse white on black
% Fore = color_white,
% Back = color_black,
% sets random colors for front and back
% randomColor(Fore, Back),
% Sets greys for front and back
% randomGrey(Fore, Back),
picWin : setForeColor(Fore),
picWin : setbackColor(Back),
picWin : setBrush(brush(pat_Solid, Back)),
picWin : drawFloodFill(pnt(1,1), Back),
...
XT =convert(integer, math::random(220)),
YT = convert(integer, math::random(220)),
% draw the text ....
picWin : drawTextInRect(rct(XT,YT,X2,Y2),MOrse, [dtext_Left ,dtext_Wordbreak]),
% save the image
PIC = picWin : getPicture(),
wordname(RAW, NAME),
FileName = string::concat("MORSE ",/* RAW*/NAME, "-", IN, ".BMP"),
vpi::pictSave(PIC, FileName),
fail.
drawGraphicMorse(_INint).
P.
AI Rules!
P.
P.
-
- VIP Member
- Posts: 83
- Joined: 6 Mar 2000 0:01
-
- VIP Member
- Posts: 83
- Joined: 6 Mar 2000 0:01
-
- VIP Member
- Posts: 215
- Joined: 24 Apr 2007 12:26
imageType
Hi,
I suspect that this line is wrong in Kari's solution
I suspect that this line is wrong in Kari's solution
Code: Select all
TYPE = imageType(fileName::getExtension(FileName)),
TIA, Regards,
Frank Nagy
Frank Nagy