Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » Draw, Display, Images, Bitmaps, Icons » image viewer
image viewer [message #3094] Sat, 06 May 2006 21:34 Go to next message
mjkoskin is currently offline  mjkoskin
Messages: 5
Registered: May 2006
Promising Member
hi all,
this is my first post and also my first attempt to code ANYTHING gui in c++, so please bear with me. I've coded some simple things with java and not so simple things in tcl/tk, but c++ and especially ms-windows platform is very new to me. I got theIDE working with vc++ 2005 express and have been compiling the examples. But now I'd like to code a real program, a blind deconvolution program, which works now as a console app, but I'd like to add the parameters and also to see a preview in a gui. The problem is that I can't figure out how to display a scrollable image with upp. I haven't found an example of displaying an image, so if someone knowing the guts of upp could post a simple example of a scrollable image viewer and also tell me how to set Image's data from a array. I'm reading the image with openCV library, so I have IplImage, from which I need to extract the data to Image and then display it (ImageDraw I think).

upp looks the best option to do this, because I can create a linux and windows app in the same time.

thanks

-matti
Re: image viewer [message #3095 is a reply to message #3094] Sat, 06 May 2006 22:03 Go to previous messageGo to next message
fudadmin is currently offline  fudadmin
Messages: 1298
Registered: November 2005
Location: London, UK
Senior Contributor
Administrator
What format images have you got?
Can you display not scrollable image now?
Is it possible to use OpenCV without DirectX SDK?
Also, you can try to play with nImage package...
Re: image viewer [message #3096 is a reply to message #3095] Sat, 06 May 2006 22:05 Go to previous messageGo to next message
fudadmin is currently offline  fudadmin
Messages: 1298
Registered: November 2005
Location: London, UK
Senior Contributor
Administrator
some examples:
http://www.arilect.com/upp/forum/index.php?t=msg&th=42&a mp;start=0&
Re: image viewer [message #3097 is a reply to message #3095] Sat, 06 May 2006 22:40 Go to previous messageGo to next message
mjkoskin is currently offline  mjkoskin
Messages: 5
Registered: May 2006
Promising Member
thanks for the reply.
OpenCV doesn't necessarily need any sdks. In my console app, reading the image was with opencv, as it's simple and it reads variety of ímage files. Also smoothing and convolution is made with opencv, so I didn't need anything else (except fftw3).

No, I'm not that far that I could display anything yet, even opening a file is still obscured, but there are examples I can count on Smile But there's so much things completetly new to me, so it takes time to learn upp, so an example would be nice.

-matti
Re: image viewer [message #3098 is a reply to message #3097] Sat, 06 May 2006 22:53 Go to previous messageGo to next message
fudadmin is currently offline  fudadmin
Messages: 1298
Registered: November 2005
Location: London, UK
Senior Contributor
Administrator
mjkoskin wrote on Sat, 06 May 2006 21:40

thanks for the reply.
OpenCV doesn't necessarily need any sdks. In my console app, reading the image was with opencv, as it's simple and it reads variety of ímage files. Also smoothing and convolution is made with opencv, so I didn't need anything else (except fftw3).

No, I'm not that far that I could display anything yet, even opening a file is still obscured, but there are examples I can count on Smile But there's so much things completetly new to me, so it takes time to learn upp, so an example would be nice.

-matti



Have you tried from there?
some examples:
http://www.arilect.com/upp/forum/index.php?t=msg&th=42&a mp;a mp;start=0&
Re: image viewer [message #3099 is a reply to message #3094] Sun, 07 May 2006 09:40 Go to previous messageGo to next message
mjkoskin is currently offline  mjkoskin
Messages: 5
Registered: May 2006
Promising Member
yes I've looked at them, but why the image is set as label?
Re: image viewer [message #3100 is a reply to message #3099] Sun, 07 May 2006 11:40 Go to previous messageGo to next message
fudadmin is currently offline  fudadmin
Messages: 1298
Registered: November 2005
Location: London, UK
Senior Contributor
Administrator
mjkoskin wrote on Sun, 07 May 2006 08:40

yes I've looked at them, but why the image is set as label?



Why are you unhappy with label? You wrote:
"I need to extract the data to Image and then display it (ImageDraw I think)."
Label is sufficient to "display it" Smile
And it has already Paint and ImageDraw inside. (You can study LabelBase.h/cpp in CtrlLib if you need examples. find w.DrawImage(ix, iy, limg, lcolor)Wink
So you don't have to program it. Even more you can add nice borders and/or text. e.g if image not found or loading was incorrect.

And also you can easily (I think) make scrollable image viewer
using ideas from:
http://www.arilect.com/upp/forum/index.php?t=msg&th=260& amp; amp; amp;start=0&
if you change buttons to labels.
Edit1: Or you can use the same buttons if you want to click on you image and open you image editor etc.
btn.SetImage(const Image& img);
Edit2: But if you need zooming, then you must use something from nImage.

[Updated on: Sun, 07 May 2006 12:03]

Report message to a moderator

Re: image viewer [message #3102 is a reply to message #3100] Sun, 07 May 2006 13:32 Go to previous messageGo to next message
mjkoskin is currently offline  mjkoskin
Messages: 5
Registered: May 2006
Promising Member
thanks for the explanation. I'm still thinking in terms of tcl/tk Embarassed

I coded my first program with upp. It has a button to load image and display it as in the examples posted in this forum in label. And it works. Now I need to adjust the placings.

One thing still is unclear: how to copy data to Image-class. I tried to look at the code, but it says nothing to me. And make the label scrollable.


thanks
-matti
Re: image viewer [message #3103 is a reply to message #3102] Sun, 07 May 2006 13:46 Go to previous messageGo to next message
fudadmin is currently offline  fudadmin
Messages: 1298
Registered: November 2005
Location: London, UK
Senior Contributor
Administrator
mjkoskin wrote on Sun, 07 May 2006 12:32



1. One thing still is unclear: how to copy data to Image-class. I tried to look at the code, but it says nothing to me.

2. And make the label scrollable.

thanks
-matti



1. That's why I asked what format is/are your image(s)...?
2. Try my "Scrollable area" (link with the code in the previous post)
Re: image viewer [message #3106 is a reply to message #3094] Sun, 07 May 2006 15:14 Go to previous messageGo to next message
mjkoskin is currently offline  mjkoskin
Messages: 5
Registered: May 2006
Promising Member
thanks,

scrollable area works, I'm able to view a complete image by srolling with sliders. (Though the sliders are both horizontal Sad

The image read by opencv consists of array of chars, B G R B G R ... and aligned with 4 byte boundaries. It's bit tricky to get the value: img->imageData[x+y*img->widthStep] returns the pixel (one color) at (x,y). So a routine to set a pixel in Image is needed.

thanks
-matti
Re: image viewer [message #3107 is a reply to message #3106] Sun, 07 May 2006 15:40 Go to previous messageGo to next message
fudadmin is currently offline  fudadmin
Messages: 1298
Registered: November 2005
Location: London, UK
Senior Contributor
Administrator
mjkoskin wrote on Sun, 07 May 2006 14:14

thanks,

1. Though the sliders are both horizontal Sad

2. The image read by opencv consists of array of chars, B G R B G R ... and aligned with 4 byte boundaries. It's bit tricky to get the value: img->imageData[x+y*img->widthStep] returns the pixel (one color) at (x,y). So a routine to set a pixel in Image is needed.

thanks
-matti



1. which u++ version have you got? Vertical slider was introduced not long ago. I think, then you just need to make height>width

2. You can read my "U++ spying" lessons
http://www.arilect.com/upp/forum/index.php?t=msg&goto=29 91&&srch=spying#msg_2991
and then spy U++ for "SetPixel"... (actually in the Draw package).
Re: image viewer [message #3117 is a reply to message #3094] Sun, 07 May 2006 21:57 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 12105
Registered: November 2005
Ultimate Member
mjkoskin wrote on Sat, 06 May 2006 15:34


I haven't found an example of displaying an image, so if someone knowing the guts of upp could post a simple example of a



I have to feel guilty responding this post: all the Image stuff is at the approaching end of complete refactoring (implementation and unfortunatly interfaces too). Means, any code using advanced Image things (PixelArray etc) will have to be redone soon... Sad

Well, let us do it to the advantage. New Image is almost ready, last missing piece (ide/IconDes) has no influence on development, so I am posting the new library here. Just copy files to your MyApps folder so that they will supersede standard packages.

The new Image is quite simple:

- pixel format is always RGBA (4 x 8bit)
- use ImageBuffer to create / modify
- use Image to pass around / display
- use Raster to read other formats (like .PNG, .GIF)
- use RasterEncoder to write other formats
- RasterFormat describes formats

To display image, draw it Smile I guess this example will help you:

void MyApp::Paint(Draw& w)
{
.....
   ImageBuffer ib(30, 30);
   memset(ib, 0x80, sizeof(RGBA) * ib.GetLength());
   Image img = ib;
   w.DrawImage(10, 10, img);
......


(Assigns 0x80 to all channels, means creates gray box with 50% opacity (alpha = 128)) and draws it at 10,10).

Mirek
  • Attachment: ndraw.zip
    (Size: 1.03MB, Downloaded 1091 times)
Re: image viewer [message #3390 is a reply to message #3117] Tue, 23 May 2006 10:03 Go to previous messageGo to next message
mr_ped is currently offline  mr_ped
Messages: 801
Registered: November 2005
Location: Czech Republic - Praha
Experienced Contributor

luzr wrote on Sun, 07 May 2006 21:57


(Assigns 0x80 to all channels, means creates gray box with 50% opacity (alpha = 128)) and draws it at 10,10).



Why exactly 0x80, which is ambiguous for alpha? Smile
Why not 0x40, which would reveal whether the alpha is 25% or 75% in such case? Smile
I think you wanted me to ask... Wink So you win, I'm asking... Smile
Re: image viewer [message #3391 is a reply to message #3390] Tue, 23 May 2006 10:35 Go to previous message
mirek is currently offline  mirek
Messages: 12105
Registered: November 2005
Ultimate Member
mr_ped wrote on Tue, 23 May 2006 04:03

luzr wrote on Sun, 07 May 2006 21:57


(Assigns 0x80 to all channels, means creates gray box with 50% opacity (alpha = 128)) and draws it at 10,10).



Why exactly 0x80, which is ambiguous for alpha? Smile
Why not 0x40, which would reveal whether the alpha is 25% or 75% in such case? Smile
I think you wanted me to ask... Wink So you win, I'm asking... Smile



To keep the example simple?

Mirek
Previous Topic: Showing bitmaps or Icons
Next Topic: When I added "Draw" package to my project (605dev1), I get "plugin\z" added...
Goto Forum:
  


Current Time: Wed Nov 20 06:39:53 CET 2019

Total time taken to generate the page: 0.01542 seconds